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

Creating Tables in ADO

Status
Not open for further replies.

gavinjb

Programmer
Joined
Apr 24, 2003
Messages
106
Location
GB
I need to be able to create a table in code when certain conditions are met, I am fine at creating a simple table, my problem is trying to workout how to tell ADO to create an AutoIncrement (Autonumber) field, and Access 2k help is worst than useless as most of the times it comes up with nothing (bring back good old 97 help system that worked!!!)


Gavin,
 
I've never tried this, but I have a manual that provides the following example:

dim cmd as adodb.command
set cmd = new adodb.command

cmd.activeconnection = currentproject.connection
cmd.commandtext = "Create Table tblcustomers " & _
"(CustomerID AUTOINCREMENT (1,1) " & _
"CompanyName TEXT(50), IntroDate DATETIME, " & _
"CreditLimit CURRENCY DEFAULT 5000)"
cmd.Execute

Hope this helps. This example is under the heading Jet 4.0 ANSI-92 Extensions. I'm not sure which version you are working with.
 
There is a missing comma(,) in the above code. To make it work successfully put a comma behind the AutoIncrement(1,1), and the code will Create the table as advertised.

Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top