Results 1 to 2 of 2
  1. #1
    ismith is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    39

    autonumber in table and forms

    Hello,




    Ive got a product table with a ProductID which is an autonumber. As this increments itself - When a product is deleted that prodID disappears and it is not replaced so when a product is added it carries on with the autonumber.


    Example:


    Last ProductID used is 80.


    ProductID 80 is deleted so when a new Product is entered, it should enter onto ProductID 80 but mines goes onto 81.


    So when you look at the table there is ProductID 79 then 81.


    How can i code this so that it looks at the previous productID and then increments by 1 so there is no numbers missing in between when a Product is deleted..


    Thanks..

  2. #2
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    Autonumber doesn't work like that. It's a truly unique number. You would probably be better off ignoring the autonumber unique product id (keep it there, just never look at it except through the back end) and assigning another field called "Product Number" as a text or numeric field - you can then edit that field however you see fit...

    Two options:

    1.) Don't use autonumber, use number and then programmatically increment the numbers. (Not recommended)
    2.) Don't actually delete the records... Set up a isdeleted flag on the table (Y/N) and then filter the records so you don't see the ones you don't need. You will still have the issue with ordering being off by the deleted numbers, but you won't have an issue with orphaned records should you use that number in other tables.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-15-2011, 02:50 PM
  2. CREATE TABLE and AutoNumber fields
    By JTeagle in forum Queries
    Replies: 1
    Last Post: 11-10-2011, 03:31 AM
  3. Two Forms to One Table
    By cwild in forum Forms
    Replies: 2
    Last Post: 02-10-2011, 12:31 PM
  4. Replies: 7
    Last Post: 01-06-2011, 12:34 PM
  5. table records/forms
    By Sarge, USMC in forum Forms
    Replies: 14
    Last Post: 10-26-2010, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums