Results 1 to 8 of 8
  1. #1
    allaccess is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    2

    Post Restricting ID number length

    Hi,



    Firstly, thanks for reading this! I'm very new to MS Access so I hope this question makes sense.

    I work off a simple Access database that has two fields: an ID number generated by access, which I set to be four digits in length, and a field (Customer #) containing an eight-digit record number that is generated by an unrelated accounting system; they are not sequential numbers and are added every time I have a transaction to enter.

    In the design view of the MS Access database, I have the format of the ID number listed as /1000. So, my current database looks something like this:

    ID Customer #
    1000 98234561
    1001 37770893
    1002 45763945
    1003 83284292

    SO, I have entered enough Customer #s that I have now approached ID #1999. When I created a new record to enter a new Customer #, the ID number field added on a new digit to be a five-digit number, which is not what I wanted; I want it to proceed to 2000, 2001, etc.

    This is what it looks like now:


    ID Customer #
    1999 25255778
    11000 65654656
    11001 49476354
    11002 24657837
    Is there a simple fix for the number format to keep the ID field at four digits? THANKS IN ADVANCE!!!!

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Change it to /0000.

    That 1 in the leading spot is a constant. The record you thought was 1002 is actually record number 2.

  3. #3
    allaccess is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    2
    Thanks!

    I get that the "1" is a constant, but is there a way to keep my 4-digit IDs intact? Can I start the numbering of the database at 1000 so that it "re-numbers" the existing records and allows them to keep their existing IDs?

  4. #4
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Depends on how complicated your database is. Is that autonumber field used for ANYTHING else? Like, is it found on any other table?

    If not, then if you want to take (for example) the record with the value 3 - that you have been displaying as 1003 - and change it to permanently have the value 1003, then do these steps:

    1) Back up your database someplace safe, and do the rest of these steps in a test/junk version of the database.

    2) Copy the entire table (data and structure) MyTable -> MyTableWork

    3) Copy the entire table (structure only) MyTable -> MyTableNew

    4) Change the autonumber field on MyTableWork to a number-type field (not key, not indexed, not autonumber).

    5) Create an update query for myTableWork
    Code:
    UPDATE MyTableWork
    SET ID = ID + 1000;
    6) Run the update query.

    7) Verify the results are what you wanted.

    8) Create an append/Insert Query that looks something like
    Code:
    Insert Into MyTableNew (ID, [Customer #])
    SELECT ID, [Customer #]
    FROM MyTableWork;
    9) Run that query.

    10) See if the results are what you want.

    11) If all of that worked, then you can take a fresh copy of your production database, delete the original table and import the corrected table from your junk database.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Why is length of autonumber important? This field should be invisible to users. The Customer Number is the identifier they need to be concerned with.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    June - Since they're the only two fields in the table, it's intutitively obvious that assigning an internal number to the customer was the entire purpose of the table. Not a normal design, but it is what it is.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Still don't understand the need for custom sequential ID field. Isn't Customer # unique? If ID is just an internal PK/FK link, doesn't matter if it is sequential or 1 or 10 digits.

    BTW, advise no spaces or special characters/punctuation (underscore is exception) in field or object names. Better would be Customer_Num or CustomerNum
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Yeah, I hate # signs and spaces in field names.

    I was assuming that a printout of the formatted autonumber IDs was being used for some business procedure. That's the reason why my whole update post 4 started with the explicit assumption that there's nothing more the database is using the ID field for. If there are any other tables using ID as a foreign key, then it will take three times that many steps to get it done.

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

Similar Threads

  1. Restricting a Database
    By Arlyd in forum Database Design
    Replies: 3
    Last Post: 09-20-2013, 03:56 PM
  2. restricting access until logged in
    By gbmarlysis in forum Security
    Replies: 1
    Last Post: 02-17-2012, 06:43 PM
  3. Minimizing number length in queries
    By Madchemist in forum Access
    Replies: 2
    Last Post: 08-24-2011, 09:44 AM
  4. Convert number to fixed length text field
    By tpcervelo in forum Queries
    Replies: 1
    Last Post: 08-02-2010, 07:26 PM
  5. Restricting Results In Reports
    By Hawkx1 in forum Reports
    Replies: 0
    Last Post: 06-24-2008, 09:53 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