Results 1 to 4 of 4
  1. #1
    wnicole is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    118

    Auto number automatically next number

    Can you assist?
    My db has job number ex: 88965, 88966, etc. When I create a new job i have to remember the last...is there an easier way?


    Either a code to automatically create my new job number when I create a new job?

    Appreciate it.

  2. #2
    mrojas is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    One way of doing this would be to create two new tables, one with one numeric field (long), let's call this the Seed table; the other identical to your existing one with the exception that it would also have a new field, a key AutoNumber, let's call this the NewJobNumbers. Let's call the original job number table OldJobNumbers.
    You may want to give the new autonumber field a meaningful name, JobNoID or similar.
    Note the lowest job number you have in the OldJobNumbers table; jot this down.

    In the Seed table add a new record with its numeric field equal to the lowest job number from OldJobNumber table minus 1.

    Using a query, append the one record in the Seed table to the NewJobNumbers table.

    Again, using a query, append all records from the OldJobNumbers table into the NewJobNumbers.

    From that point forward your NewJobNumbers table will have an autonumber field that will automatically increment with each new record added.

  3. #3
    wnicole is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    118
    This one is a little scary. Don't wAnt to lose info. Let me ask first.
    1. Am I changing the names of the table...(currently job number table)
    If so this would effect everything connected to that name correct?

  4. #4
    mrojas is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    No, you won't lose any information. I would recommend trying it out on a copy of your database.

    You would make a copy of your original job numbers table and work with it. Once completed, rename your original table to something else, and rename the new table as the original table.
    For example, let's say your original table is named tblOriginalJobNumbers, make a working copy, tblOriginalJobNumbersCopy, and rename tblOriginalJobJumbers to tblOriginalJobNumberMaster. You now have two identical tables with all your original job numbers, but each table with a different name.

    Your seed table named tblSeed, your table to be used as the recipient table named tblNewJobNumbers.

    Once completed, rename tblOriginalJobNumbersMaster to tblOldJobNumbers and the tblNewJobNumbers to tblOriginalJobNumbers.
    Now you'll have three tables with the same information, tblOldJobNumbers, tblOrigianlJobNumbersCopy and tblOriginalJobNumbers.

    Verify that all three are identical and delete the tblOriginalJobNumbersCopy.

    Once you're comfortable with the results, delete the tblOldJobNumbers table.
    You'd be left with only one job numbers table, tblOriginalJobNumbers which has the auto-number field.
    Keep in mind that this new table will provide you with a new auto numbered job number, but you won't have control of changing job numbers, or skipping numbers.

    As with everything in life, there are advantages and disadvantages to doing this, and there are other ways of accomplishing the same.

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

Similar Threads

  1. Replies: 1
    Last Post: 10-16-2013, 09:41 AM
  2. Replies: 3
    Last Post: 07-12-2013, 11:53 AM
  3. Replies: 1
    Last Post: 05-07-2012, 08:21 AM
  4. Auto Number
    By sah in forum Forms
    Replies: 1
    Last Post: 04-30-2012, 07:20 AM
  5. Auto-number
    By rkski in forum Programming
    Replies: 2
    Last Post: 01-13-2010, 02:04 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