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

    How do I Disable F1 Key in VBA? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    In a Form, how do I disable (vbKeyF1) in VBA?

    Thanks, John

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

    Re: How do I Disable F1 Key in VBA? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You don't actually disable it, you try the KeyDown or KeyPress event and test for vbKeyF1 then set it to 0. Perhaps if you desribe exactly what you need, someone can give you a more detailed answer.
    Charlotte

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

    Re: How do I Disable F1 Key in VBA? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You reminded me of something I already did on other forms.

    <pre>Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
    Case vbKeyF1
    KeyCode = 0

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How do I Disable F1 Key in VBA? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Create an AutoKeys with the following line.
    This will disable the F1 key for the application.
    No need to run it, it will automatically run at startup of the application if you name the macro AutoKeys
    Francois

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

    Re: How do I Disable F1 Key in VBA? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thanks for the info

    Can I run a disable F1 key macro in form open event to disable F1 key in the form and all its sub forms, then on form close run an enable F1 key macro?

    John

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How do I Disable F1 Key in VBA? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    So far I know, AutoKeys is a macro that assign an action to some keys and are is run when the application start.
    If you give the macro another name, you can't run it to assign the keys.
    I don't know any method to revert this once the keys are set.
    If you want to disable the F1 key only for one form and his subforms you'll have to run your code for the form and each subform.
    Don't forget to set the Key Preview to yes for the form and the subforms.

    If I'm wrong, somebody can correct me.
    Francois

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

    Re: How do I Disable F1 Key in VBA? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    If you want to disable F1 in specific forms and subforms, use Form_KeyDown code in each of them.
    If you want to disable F1 in an entire database, use an AutoKeys macro as posted by Francois.

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

    Re: How do I Disable F1 Key in VBA? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thank you Francois & Hans

Posting Permissions

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