Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    That format function mask will not work with an alpha character in the data. Also, since the letters a and A are mask characters (remember, Access is not case sensitive by default), must have something to do with causing the 0000 return.



    I, too, wonder what the OP's data is really like.
    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.

  2. #17
    Join Date
    Apr 2017
    Posts
    1,681
    OP did say at start, the data are alphanumeric - i.e. this is a text field.

    =Right("0000" & StartValue,Iif(Len(StartValue)>4.Len(StartValue),4 ))
    or
    =Right("0000" & StartValue,4)
    in case the field length is limited with 4 characters.

  3. #18
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Delightful, Arvil!

    We are confused because OP said the Format() suggestion solved the issue.

    Micron, I do use control's AfterUpdate event to save altered user input.
    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.

  4. #19
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Micron, I do use control's AfterUpdate event to save altered user input.
    When that control is bound to the record that the form is on? I think you'll find that trying to update a bound control via code will generate an error when the form has a lock on that record. At least it does for me. I don't have "no locks" as a locking setting.

  5. #20
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I do it all the time. This validates their entry, dropping fat-fingers when they enter more than 2 decimal points:

    Code:
    Private Sub txtCashTips_AfterUpdate()
      Me.txtCashTips = DropDigits(Me.txtCashTips)
    End Sub
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #21
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    This should work (tested) :

    =replace(format("AB","@@@@")," ","0")

    The "@" forces leading blanks on the string, and the replace changes the leading blanks to "0", so the example above yields "00AB"

  7. #22
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yes, Micron, it works. DB been running for 10 years. I've never changed record locking on any database.
    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.

  8. #23
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Ummm, turns out I was trying to DoCmd.RunSql on the field to alter the value...

    John_G's expression works for any record if I replace the literal "AB" with a control reference.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 08-25-2015, 05:19 PM
  2. HTML characters in plain text field
    By etorasso in forum Access
    Replies: 3
    Last Post: 09-25-2014, 11:47 AM
  3. Replies: 7
    Last Post: 06-20-2014, 08:55 PM
  4. Replies: 1
    Last Post: 05-01-2014, 11:33 AM
  5. Counting Characters in a text field
    By velvettiger in forum Queries
    Replies: 1
    Last Post: 03-12-2010, 12:36 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