The code I posted is a FORM level event. I don't know of an application level event.
I have not tried (actually, I have not needed) a control level keydown event.
You could
try putting code in a standard module and calling it from the Form KeyDown event.
But you
must have code for the Form KeyDown event in
every form.
Something like this (
air code):
(each form)
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call OpenHelp(KeyCode, Shift, Me.Name)
KeyCode = 0
End Sub
(standard module)
Code:
Sub OpenHelp(pKeyCode As Integer, pShift As Integer, pFormName As String)
Select Case pKeyCode
Case vbKeyF1
Select Case pFormName
Case "Form3"
MsgBox "You pressed F1 in form: " & pFormName
Case "Form2"
' Open different form help here
End Select 'pFormName
Case Else
End Select 'KeyCode
End Sub
You could also leave out the code to select which form the help is for for and just use one help screen (PDF document).
=============================
Warning: I corrupted the VBA project one time by copying a subroutine in a report and pasting it in 5 other reports without compiling the IDE or dB.
It took me two weeks to recover the FE.
What I do now to copy code into multiple forms/reports:
Copy the code and paste it into a text file.
Begin loop
...Open the form/report, click on the event (in this case it will be the form KeyDown event) and paste only the lines
between "Sub" and "End Sub".
...Compile the code in the IDE (Debug-compile).
...Save the form/report.
..."Compile and Repair" from the menu (the whole dB).
loop until done