Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2002
    Location
    UK
    Posts
    67

    Thumbs down Unanswered: HELP! Autonumbers behaving oddly.

    Hi,

    Yesterday, I appended a record in one of the tables to create an older autonumber(eg2000). The actual last autonumber was 2765. Since that append query, I am getting an error message for Creation of duplicate records and this is cauisng havoc on production database.

    A faster help will be highly appriciated as to how to restore to the latest record number.

  2. #2
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    I guess you'll have to do it in the same way-an append query with one record and append a calculated field:
    MyNumber: 2765

    Then delete this record.

    Or, programatically:

    Sub RestoreAutoNumber()
    Dim rst as DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("Select [IDField] From TableName Where 1 = 0;")
    rst.addNew
    rst("IDField") = 2765 'or whatever was the last number
    rst.Update
    rst.Close
    Set rst = Nothing
    End Sub

    Check your table for the record, then delete it.


    Regards,

    Dan

  3. #3
    Join Date
    Jan 2002
    Location
    UK
    Posts
    67
    I have gone thro' the same step of using an append query with the last generation number and then deleted the record, But before that had to take off all the unique keys and then had to get them restored.

    Any way thanks a lot for your help.

  4. #4
    Join Date
    Jul 2002
    Posts
    67

    Post

    If you haven't compacted the database, then try that. It will re-index all the records and start the autonumber process after the last autonumber value. It's worth a shot.
    Don't do today, what can be done tomorrow.

  5. #5
    Join Date
    Jan 2002
    Location
    UK
    Posts
    67
    Thanks a lot for your help, Now the database is working fine

Posting Permissions

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