How do you increment the primary key

Results 1 to 2 of 2

Thread: How do you increment the primary key

  1. #1
    Join Date
    Dec 1969

    Default How do you increment the primary key

    Hi, I am having a problem with an data entry form using SQL(MSaccess) in ASPs. The problem is that I have to increment my primary key every time I enter a new record. The only way I can think of doing it is to read in the last value in the primary key field, increment it and write it back to the database along with the rest of my data. This is a bit long winded and I was wondering if anyone new of a shortcut or a quicker way to do this. <BR><BR>i.e. I am trying to get around this error message:<BR><BR>[Microsoft][ODBC Microsoft Access Driver] The changes you requested to the table were not<BR>successful because they would create duplicate values in the index, primary key, or relationship.<BR>Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index<BR>to permit duplicate entries and try again.<BR><BR>Thanks in advance <BR><BR>Dominic

  2. #2
    Join Date
    Dec 1969

    Default RE: How do you increment the primary key

    Can you set the primary key field as an auto number field? If you use the auto number field, you no longer need to worry about the increment matter. Access will do you for you on every insertion of new record.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts