Autonumber

  • Thread starter Günter Brandstätter
  • Start date
G

Günter Brandstätter

Hi all,
I tried to create an autonumber-field in a table programmatically, but I
can't find the Type 'vbAutonumber' or something similar.
Can anyone tell me how to manage this?
Using DAO3.6

Thanks in advance
Günter
 
C

CSmith

Hi,

Here's an example:

Create Table tblMyTableName (FirstName TEXT, LastName TEXT, EmployeeID
AutoIncrement)
 
G

Günter Brandstätter

Hi Calvin,
Thank you for your prompt answer.
Maybe my question was not clear enough. I have an existing table where I
want to add an autonumber-field programmatically.

Thanks
Günter
 
C

CSmith

Hi,

You're welcome! :)
I have an existing table where I
want to add an autonumber-field
programmatically.

Okay, here's another example:

Alter Table tblAddAutoNumberToMe Add MyAutoNumber AutoIncrement
 
G

Günter Brandstätter

Hi Calvin,

thank you for your help,
it took me some time to find out how to understand your code, but I found
that it was SQL.
I used
strSQL="Alter Table tblAddAutoNumberToMe Add MyAutoNumber AutoIncrement"
dbs.Execute(strSQL)

thanks again
Günter
 
C

CSmith

Hi Günter,

Sorry for the confusion. I assumed that you wanted SQL, which is a more
elegant approach in this case [IMO] than the CreateField method. Glad it all
worked out for you. :)
 

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