How to create an auto number field?

  • Thread starter Thread starter Ben
  • Start date Start date
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

--
 
Back
Top