By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

inserting autonumbers in SQL.

P: n/a
I have a two value table where the first field is an autonumber. I
wrote an SQL statement in visual basic for applications to insert but
it fails.

This is the code:

DoCmd.RunSQL "INSERT INTO Table1 VALUES(,cat);", True

The first one I didn't include a value because it is an autonumber and
I expected JET to automatically put in the next value. How can I get
it to work?

thanks.

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Karen Hill wrote:
I have a two value table where the first field is an autonumber. I
wrote an SQL statement in visual basic for applications to insert but
it fails.

This is the code:

DoCmd.RunSQL "INSERT INTO Table1 VALUES(,cat);", True

The first one I didn't include a value because it is an autonumber and
I expected JET to automatically put in the next value. How can I get
it to work?

thanks.

Dim strSQL As String
strSQL = "Insert Into Table1 (FieldName) Values ('cat');"
DoCmd.RunSQL strSQL

You don't need to concern yourself with adding an autonumber. That is
done automatically when you insert the record.
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.