How to create an auto number field?

B

Ben

Hi all -

Environment: xp, access2003, DAO
I am trying to create a table using the following code, but for some reason,
after the code is executed, it don't always see it refreshed in the table
window:

If Not bTblExist Then
Set tdfnew = db.CreateTableDef(rs("BrokerCode"))
With tdfnew
.Fields.Append .CreateField("ID", DB_AUTOINCRFIELD, DB_LONG)
.Fields.Append .CreateField("Field1", DB_TEXT, 255)
.Fields.Append .CreateField("Field2", DB_TEXT, 255)
.Fields.Append .CreateField("Field3", DB_TEXT, 255)
.Fields.Append .CreateField("Field4", DB_TEXT, 255)
.Fields.Append .CreateField("Field5", DB_TEXT, 255)

db.TableDefs.Append tdfnew
End With
End If

Also, in the first field, as you can see I created using autoincrement but
when I open the table in design view, it does not show as autonumber but
rather just number. Help.

Thanks,

Ben

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top