Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31
  1. #16
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654

    Wait a minute. Combobox has no problem listing data in both structures. Is this combobox used for selecting only existing values or does combobox allow input of values not in list?
    I agree. seems like an odd control to do this with.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  2. #17
    Pada is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2023
    Posts
    22
    Quote Originally Posted by June7 View Post
    Wait a minute. Combobox has no problem listing data in both structures. Is this combobox used for selecting only existing values or does combobox allow input of values not in list?
    June7, the combo box is used for selecting only existing values.

  3. #18
    Pada is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2023
    Posts
    22
    Quote Originally Posted by Welshgasman View Post
    Not when you are keying it in though, surely. Might need both two events in that case,
    The first two letter (AB or CD) will be captured first based on user selection (using a combo box or other controls as June7 suggestion) . And then based on that, I use the codes as moke123 suggestion. I will take notes your Keypress event, too.

  4. #19
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If combobox is only for selecting existing values, why bother with input mask? Is data saved with the punctuation?
    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.

  5. #20
    Pada is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2023
    Posts
    22
    Quote Originally Posted by June7 View Post
    If combobox is only for selecting existing values, why bother with input mask? Is data saved with the punctuation?
    Because those two values, AB and CD have two different formats that user must follow as showed in my original post.

  6. #21
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, but if the punctuation is saved (and it looks like your input masks are set to save), they can simply type whichever structure they want. The input mask is then only useful if user is allowed to enter values not in list. Or maybe it would be useful aid for typing the value. I need to do some testing.

    Okay, tested. Input mask is helpful. However, if user accidentally selects wrong structured value from dropdown list, it errors. Might want to also filter the list. This is called "cascading" or "conditional" combobox.

    Student combobox RowSource like:
    SELECT StudentNo FROM Students WHERE StudentNo LIKE [cbxPre] & "*";

    VBA:
    Code:
    Private Sub cbxPre_AfterUpdate()
    Me.cbxStudent.InputMask = IIf(Me.cbxPre = "AB", "AB-999\-9999\-9999;0", "CD-999\-999999999;0")
    Me.cbxStudent.Requery
    End Sub
    This arrangement means user will likely type AB or CD prefix twice. Kind of annoying.
    Last edited by June7; 02-21-2024 at 01:47 AM.
    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.

  7. #22
    Pada is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2023
    Posts
    22
    Quote Originally Posted by June7 View Post
    Yes, but if the punctuation is saved (and it looks like your input masks are set to save), they can simply type whichever structure they want. The input mask is then only useful if user is allowed to enter values not in list. Or maybe it would be useful aid for typing the value. I need to do some testing.

    Okay, tested. Input mask is helpful. However, if user accidentally selects wrong structured value from dropdown list, it errors. Might want to also filter the list. This is called "cascading" or "conditional" combobox.

    Student combobox RowSource like:
    SELECT StudentNo FROM Students WHERE StudentNo LIKE [cbxPre] & "*";

    VBA:
    Code:
    Private Sub cbxPre_AfterUpdate()
    Me.cbxStudent.InputMask = IIf(Me.cbxPre = "AB", "AB-999\-9999\-9999;0", "CD-999\-999999999;0")
    Me.cbxStudent.Requery
    End Sub
    This arrangement means user will likely type AB or CD prefix twice. Kind of annoying.
    Thank you for the idea. Actually, the "AD" and "CD" are only values to be used. Therefore, these values need to be captured first to determine which input masks they need to follow. So I think the combo box is for user to select either one of these value and then the next textbox will show the value the user selected and the format (input mask) they will follow to enter their numbers. I think using the If and Else If statement in this case.
    You are right. The input mask is used to aid data entry following the required format.
    Last edited by Pada; 02-21-2024 at 07:49 AM. Reason: Aid more information

  8. #23
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Actually in your case only the first character needs to be captured to determine which mask to use?
    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. #24
    Pada is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2023
    Posts
    22
    Quote Originally Posted by Welshgasman View Post
    Actually in your case only the first character needs to be captured to determine which mask to use?
    Yes, I need to capture first two characters to determine which format the data entry person needs to follow to input data. Thanks

  10. #25
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Quote Originally Posted by Pada View Post
    Yes, I need to capture first two characters to determine which format the data entry person needs to follow to input data. Thanks
    I give up.
    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

  11. #26
    Pada is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2023
    Posts
    22
    Quote Originally Posted by Welshgasman View Post
    I give up.
    I actually just created an input box to prompt user to enter AB or CD and then based on what they enter I capture it and use if/else if statement. It seems work.

  12. #27
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Welsh made a valid point. User needs to provide only A or C to determine which mask to apply. Could modify comboboxes and code to do that.
    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. #28
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    This comes close. The difficult part is figuring out what mistakes a user may make and how to handle them.

    In the attached pressing the escape key will reset the input mask.

    Needs a little more experimenting.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  14. #29
    Pada is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2023
    Posts
    22
    Quote Originally Posted by moke123 View Post
    This comes close. The difficult part is figuring out what mistakes a user may make and how to handle them.

    In the attached pressing the escape key will reset the input mask.

    Needs a little more experimenting.
    Users have been trained to enter only AB or CD. I use an input box that pops up and prompt user to enter either AB or CD. If no AB or CD entered then nothing happens.
    Thank you, moke123, I will try your codes.
    Last edited by Pada; 02-22-2024 at 04:26 PM. Reason: Add more info

  15. #30
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    My code loads the mask on the first keystroke using A, a, C, or c. The cursor then moves to the first digit position.
    Any other key besides A or C fires a message box. Hitting Escape will clear the textbox and mask.
    Still needs some cleanup and experimenting but works OK.
    Click image for larger version. 

Name:	A.png 
Views:	13 
Size:	1.3 KB 
ID:	51539
    Click image for larger version. 

Name:	C.png 
Views:	14 
Size:	1.2 KB 
ID:	51540

    Edit: Made a few changes, one being able to tab past the textbox without issues.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Replies: 7
    Last Post: 09-16-2023, 08:54 AM
  2. Dropdown List Box-Memo List
    By trident in forum Forms
    Replies: 3
    Last Post: 11-19-2016, 12:29 PM
  3. user defined property
    By Jen0dorf in forum Access
    Replies: 4
    Last Post: 04-25-2016, 12:45 AM
  4. Replies: 8
    Last Post: 01-31-2015, 11:34 AM
  5. Add to the dropdown list
    By tanyalee123 in forum Forms
    Replies: 1
    Last Post: 11-13-2013, 01:18 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