Results 1 to 14 of 14
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310

    Format a text box

    Hi,


    How to format a text box on a form as follows:

    Three letters only first letter in Capital, space, four numbers.
    All of them are obligatory.

    Example: Bac 1230

    Thanks
    Khalil

  2. #2
    Gustav's Avatar
    Gustav is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    32
    Use:
    \B\a\c 0000

  3. #3
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Hi,
    When I typed the above value, it was replaced with:

    "Bac "0000

    And when trying to type a value in the text box it gives the following error:

    Note the text box is unbounded.
    Khalil

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,575
    https://chatgpt.com/c/680639ff-d7e0-...a-715de8eb5abc
    It does not show VBA explicitly, but the Shell option looks familiar.

    Then there is MS
    https://support.microsoft.com/en-gb/...8-6138c4aeda6d
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Gustav's Avatar
    Gustav is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    32
    "Bac "0000 works as well, as here for a value of 12:


  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,575
    Using the format from the link I posted.

    I entered in lowercase cgr1234
    The picture shows the result.
    Attached Thumbnails Attached Thumbnails Screenshot 2025-04-21 161404.png  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Welsh, the ChatGPT link does not work.

    Khalil, not clear to me what you want.

    Do you want the literal characters "Bac" or was this just an example of the alpha content and there could be any 3 letters?
    So user could input xyz 15 or XYZ 15 and you want output as Xyz 0015? I think this will require VBA.

    Can use an InputMask to force structure of 3 alpha and 4 numbers but user would have to enter all 8 characters, including any placeholder zeros and space. Then VBA in textbox After Update event could make sure lead character is upper case with:

    Me.textboxname = StrConv(Me.textboxname, vbProperCase)
    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. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,575
    Quote Originally Posted by June7 View Post
    Welsh, the ChatGPT link does not work.

    Khalil, not clear to me what you want.

    Do you want the literal characters "Bac" or was this just an example of the alpha content and there could be any 3 letters?
    So user could input xyz 15 and you want output as Xyz 0015? I think this will require VBA.

    Can use an InputMask to force structure of 3 alpha and 4 numbers but user would have to enter all 7 characters, including any placeholder zeros. Then VBA in textbox After Update event could make sure lead character is upper case with:

    Me.textboxname = StrConv(Me.textboxname, vbProperCase)
    Works for me, but perhaps as I created it, but I have used that link twice from here, rather than asking the question again?

    However that is only to show a particular format. The actual data is unchanged? That is my understanding, so if you check for it, you need 'cgr1234'
    Attached Thumbnails Attached Thumbnails Screenshot 2025-04-21 165105.png  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Welsh, just tells me "Unable to load conversation".

    Okay, did not catch onto mixing upper and lower case format characters for input mask. User still must enter all characters. Access will popup error message for invalid input.

    If you want to save value with formatted structure, set InputMask as: >L<LL\ 0000;0

    And VBA is not needed after all.
    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.

  10. #10
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Hi to all,
    thank you for all the effort to help me.
    To clear things:
    My format for this unbounded text box consists of three letters, space, and four numbers. All of them should be there.
    Examples:
    Mar 1235, Bzx 2254, or Klm 2130

    I tried the following: >L<LL\ 0000
    When pressing Enter key after typing it changes to the following: ><\L"LL 0000" (I don't know why)
    When typing the value: klm 2130
    The text box shows: LLL 0000klm 2130

    Khalil

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,575
    Upload your dB, else we will be here all day on this.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Sorry, accidentally posted twice.
    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.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Suggestion is to use InputMask property, not Format. Review posts 7, 8 and 9.
    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.

  14. #14
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Hi
    I used the InputMask as: >L<LL\ 0000;0
    Thank you all for all the help.
    Solved
    Khalil


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

Similar Threads

  1. Replies: 3
    Last Post: 04-22-2020, 01:00 PM
  2. Replies: 3
    Last Post: 12-30-2016, 10:27 AM
  3. Replies: 1
    Last Post: 02-06-2016, 05:33 AM
  4. How to format text in a text box or label
    By Abacus1234 in forum Forms
    Replies: 18
    Last Post: 01-27-2015, 03:04 PM
  5. Replies: 2
    Last Post: 07-09-2014, 06:41 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