Create Table With An Index Field

PC User

Registered User.
Local time
Today, 11:40
Joined
Jul 28, 2002
Messages
193
I'm familiar with creating a table using VBA; however, I need to create a table with an index field (aka key field). Just using some simple code, could someone show me what I need to do to include an index field when I create a new table?
Public Function CreateTable()

Dim db As DAO.Database
Dim td As DAO.TableDef

Set db = CurrentDb
Set td = db.TableDefs("MyTable")

With td
.Fields.Append .CreateField("NewField", dbText)
End With

Set td = Nothing
Set db = Nothing

End Function
Thanks,
PC
 
Thanks,

That looks like the solution. I'll give it a try.

PC
 

Users who are viewing this thread

Back
Top Bottom