Input mask with Access

  • In an access form, if a field is blank and has no input mask then when the user clicks on it, the cursor goes to the far left of the field for input. But if it has an input mask in it, then the cursor will go to wherever in the field the user clicks even if it is currently empty.

    Is there some way to make the cursor go to the far left of the field if the field is blank and there is an input mask in place?

    Of course, one answer would be to remove the input mask and use VBA on the Before Update to validate the input, but that is undesirable since that looses the advantage of showing the user where the hardcoded characters (such as dashes and decimals) are in the field.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • I haven't done an Access form in years, but there should be a way to tell it to left-justify, even with the mask. Or, might be collapsible mask characters, thats how we used to do it in some ancient version of VB.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Oh yeah, what's the mask that you are using?

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Hmm, took a look at Access, I forgot that they went to these fixed-character input masks back on the 90's, so I think that I was wrong before. I don't think that there is any simple way to do it. If you really have to have this, then I would recommend that you turn off the InputMask and then check the input in the validation event.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Thanks. It took some more playing around with it, but I found a way. I set the "On Click" property to check to ensure the field was either 0 length or null and then reset the field to 0 length string. This turns out to force it to the first character.

    I definitely consider this inelegant so if anyone knows a more elegant solutuion I would appreciate hearing about it, but for the moment this does get the job done.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Set the Selstart and SelLength property of the textbox to zero in the GotFocus event

    e.g.

    Private Sub txtUserID_GotFocus()

    txtUserID.SelStart = 0

    txtUserID.SelLength = 0

    End Sub

  • Try using an exclamation point (bang= !) at the beginning of your input mask. The ! should force data entry to begin at the left of the field.

    here's a link to all of the various input mask characters:

    http://office.microsoft.com/en-us/access/HA100964521033.aspx

    --pete

  • peterzeke (6/11/2009)


    Try using an exclamation point (bang= !) at the beginning of your input mask. The ! should force data entry to begin at the left of the field.

    here's a link to all of the various input mask characters:

    http://office.microsoft.com/en-us/access/HA100964521033.aspx

    Really? I was pretty sure that the "!" was actually for left-to-right languages like Hebrew. Which, if true, would make the text fill and display backwards.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply