Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    May 2001
    Location
    Ventura, California, USA
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Entering Field Alternative (2000 SR1)

    For most fields/ controls, when I enter the field I want to select the entire field. And that's how I have my option set (Tools> Options, Keyboard, Behavior entering field).

    But I have one textbox (memo field) that needs to be different. When I enter that field, I want to "Go to end of field" so that typing in that field will not automatically replace its entire contents.
    I'd like to set make that happen OnEnter or with some similar event - or actually set the property for that text box. But I cannot figure out how/where to do that. Please help...

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Entering Field Alternative (2000 SR1)

    Try this. Create this sub in a standard module:

    Public Sub SelectEnd(ctl As Control)
    ctl.SelStart = Len(ctl)+1
    End Sub

    Now in your textbox, use the GotFocus event to call SelectEnd and pass it the control, something like this:

    Private Sub Text1_GotFocus()
    SelectEnd Me!Text1
    End Sub
    Charlotte

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Entering Field Alternative (2000 SR1)

    In the event the field is formatted, should you use this instead?

    ctl.SelStart = Len(ctl.text)+1
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Star Lounger
    Join Date
    May 2001
    Location
    Ventura, California, USA
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Entering Field Alternative (2000 SR1)

    Thank you!
    That worked great on the first form I was trying it on.
    But then I tried it on several others, and on a couple I get an error message: 13, "Type mismatch".

    I cannot figure it out; and I'm unable to capture the error (If Err.Number = 13 Then...).

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Entering Field Alternative (2000 SR1)

    What type of control were you trying it on? Type mismatch can indicate a variety of things. You'll have to post the line where the error occurred and some information about the control itself before anyone can guess at the answer.
    <hr>I'm unable to capture the error <hr>
    Did you turn on error trapping or at least insert an "On Error Resume Next" line in the code? Otherwise, you can't trap the error.
    Charlotte

Posting Permissions

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