Results 1 to 4 of 4
  1. #1
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89

    add a 0

    Greetings,



    Is there a code I could write that will add a 0 infront of a 3 digit number: Ex: 235 I want to show as 0235.

    v/r
    novice

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

    Format([fieldname],"0000")
    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
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    I just tried that and it turned 5056 into 0026 and 256 into 0022, I apologize about not stating correctly but I just want to add a 0 in front of 256 and not have it change any 4 digit number that I already have.
    v/r
    novice

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Then I don't understand the issue because the function works for me.

    Format(235, "0000")

    returns

    0235

    Format(5056, "0000")

    returns

    5056

    Confirm by typing in the VBA immediate window:

    ?Format(235, "0000")
    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.

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

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