Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2010
    Posts
    15

    Unanswered: function keys (like F4) not working in Popup form?

    Hi

    Is there some way to work around the fact that the function keys like F4 are not working when a form is in popup mode? I use many popups and many comboboxes that I would like to enter using my keyboard.
    thanx
    DJ
    Holland

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You can detect the use of any key, whether the form is in popup mode or not. Set the KeyPreview property of the form to Yes (True) and use this code:
    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
        If KeyCode = 115 And Shift = 0 Then
            ' key F4 pressed
        End If
        
    End Sub
    It even works when the form is Modal.
    Have a nice day!

  3. #3
    Join Date
    Apr 2010
    Posts
    15
    thanx for your reply

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    In point of fact, <F4> should drop down a combobox that has focus, regardless of the popup/modal settings. You don't, perchance, have a keyboard with an F Mode key do you? This button toggles the F Keys between their normal functions and functions that can be programmed by the user, and are easily hit accidentally. I know when I've hit mine when <F1> doesn't bring up Access Help as it should.

    But if you're trying to avoid use of the mouse, why not have the box drop down when it is entered?

    Code:
    Private Sub YourComboBox_Enter()
      Me.YourComboBox.Dropdown
    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

  5. #5
    Join Date
    Apr 2010
    Posts
    15
    Ok, it worked, I combined both suggestions and on a specific form I can now user F4 to dropdown the items in the combobox,
    but
    I have about 20 forms. How can I make a public function out of the code? I now have something like:

    If frm.KeyDown(115, 0) = True Then
    If TypeOf Screen.ActiveControl Is combobox Then
    Screen.ActiveControl.Dropdown
    End If
    End If

    It doesn't work when I put this in a module. Anyone?

  6. #6
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by dirkjan75 View Post
    Hi

    Is there some way to work around the fact that the function keys like F4 are not working when a form is in popup mode? I use many popups and many comboboxes that I would like to enter using my keyboard.
    thanx
    DJ
    Holland
    I just tested this on Win XP with Access 2003 and 2007. I also tried with Win 7 and Access 2003 and 2007. The F4 key worked just fine with a combo box on a form with popup = yes.

    Curious, are you using Access 2007? If you are then make sure you have SP2 installed.

    Have you tried testing your databases on different machines just to make sure it is not a hardware issue, as previously pointed out?
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  7. #7
    Join Date
    Apr 2010
    Posts
    15
    Hi

    In a new DB it worked, the F4 in popupmode. So I am wondering what in my code could blok the F4 from working? It is in all windows. Anyone?

  8. #8
    Join Date
    May 2010
    Posts
    601
    first thing I would look for is if there is an autokeys macro that is trapping the keys.

    Do you have an autokeys macro?
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  9. #9
    Join Date
    Apr 2010
    Posts
    15
    I don't know. I have no macro's at all, I only program in VB. Where can I check if I have an autokey macro?

  10. #10
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by dirkjan75 View Post
    I don't know. I have no macro's at all, I only program in VB. Where can I check if I have an autokey macro?
    I also normally only use VBA code. The exception is the special macros named AutoExec and AutoKeys

    In the database container or the Navigation pane go to Macros.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  11. #11
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Note also that it's possible that some other program running in the background might utilize the F4 key (such as monitor type program or ATI Control Card program, etc..)

    This could cause conflict with the F4 key coding.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  12. #12
    Join Date
    Apr 2010
    Posts
    15
    testing on an other computer did work, the F4 function works on this machine. So maybe it is the hardware of the system that messes with my F4 thing! thankx for looking in to this

Posting Permissions

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