Results 1 to 3 of 3
  1. #1
    craig1988 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2014
    Posts
    82

    Append leading zeros to a field during an appemd query

    Hi All



    I have an append query that adds records to a master table. The inputter enters a start number (StartSerial) and an end number (EndSerial). These numbers will be used to generate a serial number of 6 characters.

    I need the append query to append leading zeros to create the 6 character serial number.

    So

    If (len(StartSerial)=1) Then StartSerial = "00000" + StartSerial
    Else If (len(StartSerial)=2) Then StartSerial = "0000" + StartSerial and so on...

    Thats the logic above.

    I need this adapted so the query can do this.

  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,902
    If you always want six characters with placeholder zeros, try:

    Format([input number],"000000")
    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
    craig1988 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2014
    Posts
    82
    So Simple

    Thanks June7

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

Similar Threads

  1. Trying to get leading zeros to show
    By Pegasus_Angel in forum Access
    Replies: 3
    Last Post: 10-25-2012, 11:40 AM
  2. Replies: 1
    Last Post: 07-11-2012, 07:16 PM
  3. VBA Format Append Leading Zeros
    By Jester0001 in forum Programming
    Replies: 10
    Last Post: 04-03-2012, 09:54 PM
  4. Leading Zeros
    By dirtbiker1824 in forum Access
    Replies: 1
    Last Post: 03-14-2011, 02:16 PM
  5. Adding Leading Zeros
    By jo15765 in forum Access
    Replies: 13
    Last Post: 11-20-2010, 11:11 PM

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