Results 1 to 9 of 9

Thread: Input Masks

  1. #1
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941

    Unanswered: Input Masks

    I have a form with 2 fields with medium time format.
    I put an Input Mask of "99:00\ >LL;0;_" in.
    The first user I had test the form uses the mouse instead of tab,
    so when he clicks in the control, he ends up in the middle of the field.
    Is there anything I can do to move the cursor to the beginining of the field when he clicks anywhere in the field?
    Inspiration Through Fermentation

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Private Sub TestData_GotFocus()
    if isnull(me!TestData) then
    Me!TestData = ""
    else
    'Decide here if you want to set the field to null if it has a value in it or just the hashline to show where the field's been clicked (ie. do nothing) or if there is a value and you want to go to the beginning of the field, possibly set Me!TestData = me!TestData. Or mabye set another unbound hidden field with the value of this field and then set this field to "" and then back to the value from the hidden field. This may not work but I'll keep researching (once the unbound field has the value you could leave it as "" and then in the lostFocus event test to see if there's data in the field (ie. if(isnull(me!TestData)) then me!TestData = me!OtherUnboundFieldHoldingValue. This would handle if someone accidently clicked on the field and saw the value vanish. They click off the field and the value is back there. I need to think about it more on what to do if the field has a value but you can definately do it to the front of the box using Me!TestData = "" on either case unless you need the existing value where I might write that value to another unbound invisible field.
    end if
    End Sub

    Disregard this junk! See Missinglinq's code below!
    Last edited by pkstormy; 07-25-07 at 10:55.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Anytime you use an input mask you should use this code to move the cursor to the beginning of the textbox:

    Code:
    Private Sub YourTextBoxName_Click()
       Me.YourTextBoxName.SelStart = 0
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    That works a LOT better than the answer I gave!! I don't recall seeing that in 2000. Since I work with 2003 now I can't recall. Is it also available in 2000 Missinglinq?

    Thank you also.
    Last edited by pkstormy; 07-25-07 at 10:56.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I'd never heard of it either. I'm using XP, and it's available there.
    It sure looks like it will do what I need.
    Thanks
    Mark
    Inspiration Through Fermentation

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Been in every version since Access 95! Can't say about flagship version, or should I say the albatross version, 2007!

    Control.SelStart = 0 sends cursor to beginning of textbox
    Control.SelStart = Len(Control) sends cursor to end of text, if any
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Very cool. Can't believe I've never come across that in 15 years of developing.
    Inspiration Through Fermentation

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Heh heh - I've seen it but never been able to find a use for it (only because it has come up on the forum once or twice though). This is defo one to remember though - didn't think of that. Nice job ML.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  9. #9
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    To me, that's one of the attractions of Access; no matter how long you've used it, there's always something new to learn!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •