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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a DAO Autonumber field in new table 1

Status
Not open for further replies.

GIJoeFigure

Technical User
Jun 16, 2004
27
0
0
US
I have VBA code that makes a Tabledef if its name doesn't already exist in the database and adds it to my other tables, but I wish to set its ID field to Autonumber (Long). Any ideas as to how to do this?

Thanks

 
I forgot to add that I'm using Access 2000 and I know its easy to create an autonumber field but I was hoping that you can set one up while appending fields to a tabledef

 
You may do it with DDL:
DoCmd.RunSQL "ALTER TABLE yourTable ADD COLUMN myID COUNTER(1,1);"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV, you've done it again!! So many times you've helped me. Thanks. One last thing, is it possible to move the column to be the first in the table because it shows up last in the table after being added on by the sql.

 
In relational database the order of table columns is irrelevant as it is the select list that determines the order of the columns returned by the query.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top