Results 1 to 12 of 12
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Currently my Options.., Keyboard, Behavior entering field, is set to Select entire field.

    Is there a way in code when a particular form is opened to change this behavior to Go to end of field for all fields on the form without having to handle each field individually like I am now with something like On_Enter set to Screen.ActiveControl.SelStart = Screen.ActiveControl.SelLength?

    Thanks, John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You could use the following code in the form module:

    Above all Subs and Functions:
    <code>
    Private intOpt As Integer
    </code>
    Anywhere below that:
    <code>
    Private Sub Form_Activate()
    intOpt = GetOption("Behavior Entering Field")
    SetOption "Behavior Entering Field", 2
    End Sub

    Private Sub Form_Deactivate()
    SetOption "Behavior Entering Field", intOpt
    End Sub
    </code>
    This code sets Behavior entering field to End of field when the form is activated, and resets the default setting when the form is deactivated.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I like that, opens up a lot of possibilities!

    Thanks, John

  4. #4
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    This procedure is something I would like to use. Is there a reason why this technique will not work with Access97?

    Thank you,
    Ron

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    If I remember correctly, this code would also work in Access 97.

  6. #6
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    For some reason the code does not change the keyboard options as desired. I even made a copy and converted the database to A2K and it will not make the changes there either. Any other ideas?

    Thank you.
    Ron

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Sorry, no. It works for me in Access 2002 and 2003, and I can't easily test in Access 97 any more.

  8. #8
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    The code that you have works just fine in 97 and 02 - - - when the form is not popup or modal. <img src=/S/blush.gif border=0 alt=blush width=15 height=15>
    <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

    Thanks again
    Ron

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    The On Activate and On Deactivate events do not occur for a popup form, so the code will not work for a popup form.

    The events do occur for a modal form though, so the code should work for a form that is modal but not popup...

  10. #10
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    The popup form was the culprit. Thanks again!

    Ron

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You could use the On Load and On Close events of a popup form. The disadvantage is that the option won't be reset when the user clicks away from the popup form. But if the form is popup AND modal, the user can't do that, so using the On Load and On Close events is sufficient.

  12. #12
    Star Lounger
    Join Date
    Apr 2002
    Location
    Onekama, Michigan, USA
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Keyboard Behavior for a Form (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thank you for the additional information.

    Ron

Posting Permissions

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