Results 1 to 6 of 6
  1. #1
    NikoTheBowHunter is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    58

    Update code to show leading zeros

    so with some help from an experienced Access user on this site I was able to get the following code to work on my form:



    Private Sub Enter_New_Note_Click()
    Me.[Notes History] = Date & " | " & Me.Text138 & vbCrLf & Me.[Notes History]
    Me.Text138 = Null
    End Sub

    code works, enters new line of text with the date in front. Only thing I would like to update is that the date shows leading zeros so all my comments line up in the box. Is there a way to do this or am I just SOL?

    And please don't hate to hard on my coding, this is my first db ever and its a slow and fun learning process!!

    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    if text123 has the number , use the format command

    format(me.text138,"0000")

  3. #3
    NikoTheBowHunter is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    58
    text123 is an unbound text box where a user can enter his or her notes, then press the Add New Note button, which runs the above code and puts it all into the [Notes History] field with the date in front of the notes. Can I still use the format(me.text138,"0000") or no? If so, please show me how I should write out the code with my existing code as I have no idea what it should look like.

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Or
    Me.[Notes History] = Format (Date, "mm/dd/yyyy") & " | " & me.text138 & vbCrLf & Me.[Notes History]

  5. #5
    NikoTheBowHunter is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    58
    I'll give this a try when I get to work in the morning. Thanks for the help, cheers.

  6. #6
    NikoTheBowHunter is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    58
    the above code worked! thanks! I did have to change the code a bit, since the box displaying it was rich text, had to take out the vbcrlf and us <br> instead so it looks like this:

    Me.[Notes History] = Format(Date, "mm/dd/yyyy") & " | " & Me.Text138 & "<BR>" & Me.[Notes History]

    thanks again for the help!!!

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

Similar Threads

  1. Delete Leading Zeros
    By KathyCo in forum Queries
    Replies: 4
    Last Post: 11-01-2016, 11:59 AM
  2. Do not add leading zeros
    By phifer2088 in forum Access
    Replies: 5
    Last Post: 03-02-2015, 10:05 AM
  3. Trying to get leading zeros to show
    By Pegasus_Angel in forum Access
    Replies: 3
    Last Post: 10-25-2012, 11:40 AM
  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