Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create and populate an auto-increment Primary Key field with ADO

Status
Not open for further replies.

RobJDB

Programmer
May 13, 2002
44
GB
Hello,
I've created a table and populated all its fields using ADO and now I want to add an auto-increment field to it, fill it up, and make this the primary key, all within ADO. I've found bits of information on these forums but nothing comprehensive.

Also, when I'm creating fields using

With myNewTable
.Fields.Append .createfield(fname, ftype, fsize)
End With

how can I set these fields to allow zero length?

Thanks,

Rob
 
If you are using
myNewTable.Fields.Append .createfield(fname, ftype, fsize)

you won't need to "populate" the autonumber field - it will do that automatically - that's what the "Auto"number does for you.
 
Okay, but how do I create it with the Autonumber property and make it a primary key?

Thanks,
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top