Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / January 2005

Tip: Looking for answers? Try searching our database.

Add Index Property To Temp Table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry R Harrison Jr - 28 Jan 2005 23:12 GMT
I have Access 97. I have a "tmp" table that is created in code via a query
(or SQL statements), I then need to modify 2 of the fields to be index (dups
okay). I cannot for the life of me figure out how to do this in code.

The field is "Approved", it's a YES/NO field, the table is "tmpTable."

How do I do this?

LRH
Brendan Reynolds - 29 Jan 2005 00:12 GMT
The commented out lines are the lines I used to create the table. You don't
need them because, of course, the table already exists in your database ...

Public Sub AddIndex()

   Dim db As DAO.Database
   Dim tdf As DAO.TableDef
   Dim fld As DAO.Field
   Dim idx As DAO.Index

   Set db = CurrentDb
   'Set tdf = db.CreateTableDef("tmpTable")
   Set tdf = db.TableDefs("tmpTable")
   'Set fld = tdf.CreateField("Approved", dbBoolean)
   'tdf.Fields.Append fld
   'db.TableDefs.Append tdf
   Set idx = tdf.CreateIndex("Approved")
   Set fld = idx.CreateField("Approved", dbBoolean)
   idx.Fields.Append fld
   tdf.Indexes.Append idx

End Sub

Signature

Brendan Reynolds (MVP)

>I have Access 97. I have a "tmp" table that is created in code via a query
> (or SQL statements), I then need to modify 2 of the fields to be index
[quoted text clipped - 6 lines]
>
> LRH
larrytucaz@yahoo.com - 29 Jan 2005 13:51 GMT
> The commented out lines are the lines I used to create the table. You don't
> need them because, of course, the table already exists in your database ...
[quoted text clipped - 21 lines]
> --
> Brendan Reynolds (MVP)

Thanks for the code. I did fortunately find some earlier in Google
archives. The part that throws/confuses me is the Set fld=.createfield
(etc) because the field in question already exists.

LRH
Brendan Reynolds - 29 Jan 2005 17:42 GMT
Well, it already exists in the table, but not in the index.

Signature

Brendan Reynolds (MVP)

>> The commented out lines are the lines I used to create the table. You
> don't
[quoted text clipped - 29 lines]
>
> LRH
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.