Using Function Keys

mohammadagul

PrinceAtif
Local time
Today, 17:12
Joined
Mar 14, 2004
Messages
298
Hello

I Want to Use the Funtion Keys on the Keyboard for Specific Tasks..

Like

To Open Employee Form Press F1
To Open Customer Forms PressF2
....


I know how to use the Escape key to Close an Open form and save .. I Use the Following Code

Const EscapeKey as Integer = 27
If KeyAscii = EscapeKey then
Docmd.Save
Docmd.Close
Endif
Endif

The Only thing i Dont Know is the Ascii Number for F1..... F12 Key


Any Help Will Be Highly Appretiatied

Muhammad Atif
 
Hello to All the More Sophisticated and Expert Guys out there.....

Please help me in the Question. I Really Need to Know the Answer...


Thanks

Muhammad Atif
 
This what you need?

Constant Value Description
vbKeyF1 0x70 F1 key
vbKeyF2 0x71 F2 key
________
Buy easy vape vaporizer
 
Last edited:
Goto MS Visual Basic Help and type in "Keycode Constants" . it will give you a list of all key equivalents. :D
 
Create a macro - name it AutoKeys (has to be named this). Then you can code what key combinations you want to do specific tasks... Search "AutoKey Macro" for more help on this...

HTH,
Kev
 
I do the following :

Put the below code on the keydown event of the form:

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
            KeyCode = 0
            docmd.openform "yourformname1"
Case vbKeyF2
    KeyCode = 0
    docmd.openform "yourformname2"
    
    End Select

End Sub

Hope this helps your situation.

Andy
 
Put the below code on the keydown event of the form:

I tried putting your code in a switchboard form however when I pressed F1 it still opend the MSAcess Help file...is there something else I need to do.
Thanks this would be great if I can get it to work!!! :cool:
 
Debased said:
I tried putting your code in a switchboard form however when I pressed F1 it still opend the MSAcess Help file...is there something else I need to do.
Thanks this would be great if I can get it to work!!! :cool:

Thats cuz its a reserved key. To get around this you could code it with the autokey function for something like... CTRL + F1 this will get you what you need... if not then.......?

HTH,
kev
 
Debased said:
I tried putting your code in a switchboard form however when I pressed F1 it still opend the MSAcess Help file...is there something else I need to do.
Thanks this would be great if I can get it to work!!! :cool:

Make Sure your Switchboard as the focus when f1 is pressed. It should work and for info it does overwrite access help when pressed. Well it works for me.

See zip

Andy
 

Attachments

Last edited:
Hello Everyone,

I Have tried everything. But all invain. Even this codes does not work. It always opens the Access File

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
KeyCode = 0
docmd.openform "yourformname1"
Case vbKeyF2
KeyCode = 0
docmd.openform "yourformname2"

End Select

End Sub

I hope there wouldbe a more proper way to do this. i have already posted my code for Escape key. is there somthing like the one I used for Escape Key....

Sorry For Disturbance

Muhammad Atif Gul
 
I am also having the same problem, even when the form has the focus. :confused:
 
When I created a new form and used the code it worked fine. Don't know why when I added it to an existing form it would not work. Anyway thanks! :)
 
Sorry, won't work on switchboard. I have just tried it but it does work on forms.
Apologies don't use switchboards in any of my db's

Andy
 

Users who are viewing this thread

Back
Top Bottom