Can we program function keys in Access?

anil joshi

New member
Local time
Today, 22:18
Joined
Sep 2, 2012
Messages
2
Can we program function keys in Access?
For example, I want to use function key like F2, F3 etc, which when pressed,
should write some text lines (like 'My name is..etc') in the active control text box, (may be using sendkeys or any other).
 
You should be able to intercept the function keys in the KeyDown event of the form and perform your own action. E.g.:
Code:
Select Case [COLOR=Red]KeyCode[/COLOR]
    Case [COLOR=Red]2[/COLOR]
        KeyCode = 0
        Screen.ActiveControl.Value = "My name is... etc"
    Case [COLOR=Red]3[/COLOR]
        KeyCode = 0
[COLOR=Red]        ' some other action[/COLOR]
    Case Else
        ' do nothing
End Select
... where KeyCode is a parameter in the event I mentioned and 2, 3 etc represent the number of the KeyCode you want to intercept. You can use a Msgbox or Debug.Print to get the KeyCode that is related to each function key and substitute it for the numbers in the SELECT...CASE statetement.

Remember to set the Key Preview property of the form to Yes.

By the way, I wonder why you created this thread in the Queries section. It should have gone in Modules & VBA or Forms.
 

Users who are viewing this thread

Back
Top Bottom