Results 1 to 4 of 4
  1. #1
    path479 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    6

    How to add leading zeros and REFRESH the screen after user tab (or move) out of the field

    Our database has a text field which the user is required to enter a numeric project id via a form. Most of the project id is less than 6 digits long, however we need to add leading zeros to ensure it is stored as 6 digits.

    How do we add the leading zeros and, more importantly, REFRESH the screen so that the 6 digits long project id is reflected on screen/form as soon as the user tab (or click/move) out of the field in the form?



    We have a separate "Save" button

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Format([field],"000000")
    Or
    string(6-len([field]),"0") & field([field])

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Use the After Update event to change the value stored in the field:

    me![field1] = Format([field1],"000000")

    The display will be updated automatically.

  4. #4
    path479 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    6
    Thank you so much John_G and ranman256. Got it working now!

    I am new to both Access and VBA. I had tried using the format command but I put it in wrong event. Alsod I used expression builder when I should have used code builder. This has been a valuable lesson.

    Thank you again!

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

Similar Threads

  1. Replies: 3
    Last Post: 07-08-2015, 07:18 PM
  2. Do not add leading zeros
    By phifer2088 in forum Access
    Replies: 5
    Last Post: 03-02-2015, 10:05 AM
  3. Issues with leading zeros in a form field
    By apetriella in forum Forms
    Replies: 2
    Last Post: 02-10-2015, 11:27 AM
  4. Replies: 2
    Last Post: 01-26-2015, 03:53 AM
  5. Replies: 1
    Last Post: 07-11-2012, 07:16 PM

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