A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Add Index Property To Temp Table



 
 
Thread Tools Display Modes
  #1  
Old January 28th, 2005, 11:12 PM
Larry R Harrison Jr
external usenet poster
 
Posts: n/a
Default Add Index Property To Temp Table

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


  #2  
Old January 29th, 2005, 12:12 AM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

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

--
Brendan Reynolds (MVP)


"Larry R Harrison Jr" wrote in message
news:SGzKd.11370$rw.2466@fed1read04...
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




  #3  
Old January 29th, 2005, 01:51 PM
external usenet poster
 
Posts: n/a
Default


Brendan Reynolds wrote:
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

--
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

  #4  
Old January 29th, 2005, 05:42 PM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

Well, it already exists in the table, but not in the index.

--
Brendan Reynolds (MVP)


wrote in message
oups.com...

Brendan Reynolds wrote:
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

--
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Update - If statement Dan @BCBS Running & Setting Up Queries 13 December 14th, 2004 06:02 PM
Access & OleDb - generating schema changes, problem with identity/counter fields. Thomas Tomiczek [MVP] Database Design 9 November 5th, 2004 10:32 AM
Automatic filling of fields in table two from table one Jim Kelly Database Design 1 September 27th, 2004 10:16 PM
Name not showing ID is René Setting Up & Running Reports 11 June 29th, 2004 01:40 AM
At-your-survey db. Using a temp table for customised forms. Jesper F Database Design 1 May 14th, 2004 12:08 AM


All times are GMT +1. The time now is 05:20 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.