Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Function keys

Status
Not open for further replies.

mybers

IS-IT--Management
Mar 24, 2004
62
PH
Hello anyone,

just wondering if anyone can guide me how to call F keys in access forms ex. F6 is save , F1 is help etc..
Any contribution is gladly appreciated. Tnx
 
If you just want to simulate a key press then this will work:

SendKeys "{F1}"

HTH,
Eric
 
Dear mybers,

Using "SendKeys" is supposed to work, but I've had mixed success with it, and going by many postings I've read here and elsewhere, many others also have problems with it. A method I've used very successfully, however, allows you to assign any function you want to any special key, i.e. <Esc>, <Up Arrow>, <Down Arrow>, etc. You need to enter the following two subs in code:

Private Sub Form_Load()
Me.KeyPreview = True
End Sub

This sub makes Access look at the special keys when they are pressed.

Then enter:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyEscape
' Process Escape Key events.
Case vbKeyUp
' Process Up Arrow Key events.
Case vbKeyDown
' Process Down Arrow Key events.
Case vbKeyF2
' Process F2 key events.
Case vbKeyF3
' Process F3 key events.
Case vbKeyF4
' Process F4 key events.

Case Else
End Select
End Sub

Under each "Case" enter the code you want executed when the particular key is pressed.

Hope this is helpful.

The Missinglinq

&quot;It's got to be the going,
not the getting there that's good!&quot;
-Harry Chapin
 
Hello Missingling!


Thanks a lot! Did work fine...

However, I'd like to another thing...
is it possible to have a combination keys? ex ..
ALT + F2, alt+F5 etc...?

More help will be appreciated...Thanks in advance


 
Hi mybers,
You can determine whether the SHIFT, CTRL or ALT keys have been pressed in combination with any other key by using the Shift argument. If the Shift Key was pressed then the value passed is 1. If CTRL it is 2, if ALT it is 4. Any other key passes the value of 0.
Access also has the constants acShiftMask, acCtrlMask and acAltMask which you can use as well.
Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top