0

Can someone please help me with the following line. I am trying to create a table that will have a column with the Id that automatically increments when a record is inserted. This is for microsoft access.

"CREATE TABLE " & tblName & " ([P_Id] integer not null AUTOINCREMENT(100, 5))"
3
  • This is a microsoft access database. Commented Nov 20, 2012 at 21:45
  • Missed that. w3schools.com/sql/sql_autoincrement.asp Commented Nov 20, 2012 at 21:47
  • The following command doesn't work from w3schools.com .Execute "CREATE TABLE " & tblName & " ([P_Id] PRIMARY KEY AUTOINCREMENT Commented Nov 20, 2012 at 21:56

1 Answer 1

1

Try the following to create an MS Access table with an auto-number field:

"CREATE TABLE [" & tblName & "] ([P_Id] integer not null IDENTITY)"

I do not know if you can specify a start-value and increment, but you can try it.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi Mike, I know you are new to SO, but when you receive a correct answer you should "accept" the answer. This will increase your "accept percentage" and add 2 points to your reputation.
Thanks Ron, I am new. I was amazed at how fast I got answers. It was almost like everyone was just waiting for me to ask a question. How do I see the tags that I may be able to contribute?
SO is remarkable. I strongly suggest you read and digest the FAQ (stackoverflow.com/faq).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.