Results 1 to 6 of 6
  1. #1
    Hanhar is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    2

    Client ID format alphanumeric

    I use the client ID in alphanumeric format for my database purposes. The length of the ID should be 9 characters long including 8 numeric and 1 letter at the end.
    Some ID's are short like 1230L, others are longer 02153M .etc...
    How do I add leading zeros in the Clint ID so all ID's are 9 characters long with 8 numeric and 1 different letter at the end?
    I am using access 2007.


    Is this doable for excel as well?
    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    In your form , fill out the boxes needed for your alphas, have an extra box for the ID to be calculated...txtID
    when they press the SAVE button , fill the ID and have an append query add the record.

    the formula for txtID is
    'oops sorry
    i = len(txtLetters)
    txtID = string(9-i,"0") & txtLetters

    then run the query.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If this value is generated during data entry to a bound form, should not need an append query, just populate the field of record.
    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.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    How do I add leading zeros in the Clint ID so all ID's are 9 characters long with 8 numeric and 1 different letter at the end?
    This is unclear about WHEN you want to add the leading zeros.

    When you are entering the ID in a form? -> Set an input mask. Or use the before update event of the control to add the leading zeros.

    In a query for a form or report? -> MyClientID:Right("00000000" & ClientID,9)

    Data already entered in a table. -> Use an update query (or VBA code)

  5. #5
    Hanhar is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    2
    I would like to add leading zeros for client ids already entered in table. Most of the id's are shorter then 9 characters. I will also be entering the client IDs for new clients in the table.
    I tried going to design view of table and change format and mask for Client ID field property. What do I really enter in the properties and where? Format or input mask?

  6. #6
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    To update all existing fields, try this:

    string(9-len([ID]),"0") & [ID]

    For the form properties, you would us an input mask. A mask governs how data is entered, whereas a format governs how it is displayed.

    A suitable input mask might be ">00000000L"

    The first 8 characters are digits, required, and the last character is a letter, required. The ">" makes everything upper case (affecting only the letter).

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

Similar Threads

  1. Street Address with alphanumeric
    By ampstar in forum Access
    Replies: 4
    Last Post: 08-07-2014, 11:28 AM
  2. Help with Alphanumeric autonumber
    By RandyP in forum Programming
    Replies: 1
    Last Post: 06-08-2014, 05:38 PM
  3. alphanumeric primary key
    By slimjen in forum Database Design
    Replies: 4
    Last Post: 09-18-2011, 10:20 PM
  4. Replies: 1
    Last Post: 07-26-2011, 06:10 AM
  5. Format a field(AlphaNumeric)
    By Bakar in forum Database Design
    Replies: 1
    Last Post: 12-20-2010, 06:36 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