Results 1 to 5 of 5
  1. #1
    bigchicagobob is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    18

    Update Query, Inserting Variable Number of "0"

    Hello, I'm using MS Access 2010 on windows 7.



    I have a table with ~45,000. I have a column with values that each must have (1) two letters followed by (2) six numbers for a total of 8 characters per cell. Somehow numbers beginning with a zero had the zero removed, so I have cells with values like AL12345 instead of AL012345 and ZX234 instead of ZX000234. The data is saved as "text." Does anyone know how I could update the values to include the zeros? I have attempted using Format(), left(), ...etc


    Column1 - incorrect format
    Code:
    AL12345
    ZX234
    AS123456
    QW98
    PO678345
    Column2 - ideal format
    Code:
    AL012345
    ZX000234
    AS123456
    QW000098
    PO678345
    Cheers,

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Try:

    UPDATE table SET fieldname = Left(fieldname,2) & Format(Mid(fieldname,3),"000000")

    Be sure to test with a copy of the table.
    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.

  3. #3
    bigchicagobob is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    18
    Hey June7,

    Unfortunately, it did not work. Do you think an update like this would require using VBA?

    Thanks,
    Bob

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    It worked for me.

    How did it not work for you?
    Are you getting some sort of error?

    How did you try to run it?

    Are you sure you updated the table and field name references correctly?

  5. #5
    bigchicagobob is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    18
    okay works! thanks again!

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

Similar Threads

  1. Replies: 5
    Last Post: 06-26-2013, 02:29 PM
  2. inserting "dashes" into text field
    By desimoreno in forum Access
    Replies: 2
    Last Post: 05-23-2013, 11:44 AM
  3. Replies: 5
    Last Post: 03-22-2013, 01:11 PM
  4. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  5. Problem with inserting "DATE" in reports
    By Larry Fox in forum Access
    Replies: 1
    Last Post: 08-24-2011, 07:09 AM

Tags for this Thread

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