Results 1 to 8 of 8
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    input mask


    Two part question;related

    All, using access 2010. I have a SSN search field. I used the input mask to format like:
    000\-00\-0000;0;_Users are complaining that they are getting “invalid text entered” when they are inputting the correct data. I found that they are not starting at the beginning. When they click in the box; it doesn’t force them to go to the beginning of the field. So; they if they are not paying attention; they get the error. I know this is user error but how can I format so when they click in the box to begin the search; they are at the beginning of the field?

    Also; I use input mask format when they enter a new record. They do not want to have to put the hyphens in when typing the SSN. But if they put without the hyphens; they are not able to search the record because the search field is formatted input mask. Is there another solution? Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Check out SelStart method.

    Private Sub controlname_GotFocus()
    Me.controlname.SelStart = 0
    End Sub

    Did you set the input mask in table? I never make property settings such as Format and Lookup in table, only in controls on forms and reports.

    What is the code that performs the search? Format the user input and use that for the search criteria.

    Format(Me.tbxSSN, "###-##-####")
    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.

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Your users shouldn't have to pay attention. That's what computers are for.

    First, unformat the search field. If for technical reasons you need to use a formatted version for the search, then create a hidden control with the formatted version of the SSN, and have the AfterUpdate event of the text box cause the formatted, hidden field to get calculated. The advantage to this approach is that, if some user wants to type in the dashes, they can, and your after-update calculation routine can deal with it appropriately.

    Second, use the same method with an unbound SSN entry field on the data entry screen. That field's after update will update the BOUND field's SSN.

    Third, it's a tossup whether you should store the dashes in the SSN field on the database. If there is any other kind of ID stored in the same field, especially with alpha characters - EIN or such - then you should store the dashes. If not, then pure numeric is probably better.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    This would drive Mister Spock crazy, because as illogical as it seems,

    Code:
    Private Sub controlname_GotFocus()
     Me.controlname.SelStart = 0
    End Sub

    is not going to solve the problem of users 'clicking' into the Textbox at somewhere other than the beginning of the Textbox! The code has to go into the OnClick event of the Control:

    Code:
    Private Sub ControlName_Click()
     Me.ControlName.SelStart = 0
    End Sub

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Maybe need it in both events.
    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.

  6. #6
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Ok. thank you for all the responses. I'll try and post back.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Correction, since you want the start position at 0, don't need GotFocus event, just use the Click as Linq suggested.

    I have some controls where we want the start to be on 6th character so I do need the GotFocus event.
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post
    Maybe need it in both events.
    I actually put it in both, on the rare occasion when I use an Input Mask. The problem, on a distributed app, is that you have no way to know how a given user has the 'Behavior on Entering Field' Option set! If it's not set to 'Go to start of field,' you have the same even when Tabbing into the Field! Placing the code in the GotFocus event solves that. All in all, Inputs Masks are usually more trouble than they're worth! I'd rather take the time to Format after the data is entered
    , but that's just me!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Simple input mask
    By BPB6 in forum Access
    Replies: 8
    Last Post: 10-18-2012, 06:34 AM
  2. Input Mask Question
    By MM12 in forum Access
    Replies: 2
    Last Post: 09-10-2012, 11:03 AM
  3. Input Mask
    By qbc in forum Access
    Replies: 2
    Last Post: 01-20-2012, 03:27 PM
  4. Replies: 4
    Last Post: 10-31-2010, 10:35 AM
  5. Input mask
    By doobybug in forum Access
    Replies: 2
    Last Post: 06-17-2009, 09:40 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