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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using function keys on Keypressdown

Status
Not open for further replies.

mybers

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

Can you direct me on how to use function keys on forms?Ive seen some codes but it didnt' work well

Ive tried
' If keyascii=vbkeyF5 then
keycode=o
docmd.save
endif

Anymore suggestions? pls

and Perhaps adding CTRL+F5 - etc...



 
using function keys on Keypressdown
There is no Keypressdown event.
Take a look at the KeyDown event procedure in your help file.
You may also consider getting help on the KeyPreview property of your form.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV

my mistake it shouldve "On Keydown" event

But How do i call /get the Fkeys to function?

"vbkeys=...." seems to no work

other options?

 
No F1 key on your keyboard ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
How are ya mybers . . . . .

Opena module & hit F1 for Help. Select the [blue]Answer Wizard[/blue] tab and type [purple]keydown[/purple]. The info you require is here.

Also, be sure to check out the [purple]KeyPreview[/purple] property for the form. This allows the form to receive key strokes before the controls.

If ya have any problems, just c'mon back and we'll give ya all the help you need.

Flag0.gif
Remember Our Veterans! Remember Sept 11th!
 
Hello Aceman1

Sorry there wasn't any details about how to call the Fkeys/function keys. Well most of them are for any keystrokes except calling Fkeys.

Perhaps an example of a script calling the Fkeys or an example using keyascii values would be a great help.

c yah



 
mybers! . . . . .

You must have read right over it:
MicrosoftAccessHelp said:
[blue] [purple]KeyDown, KeyUp Events[/purple]:Although the KeyDown and KeyUp events occur when most keys are pressed, they are typically used to recognize or distinguish between:

Extended character keys, such as [purple]function keys[/purple].[/blue]
For further info, at the top of this page, click the [purple]Event Procedures[/purple] hyper link.

To see all the keycodes, open the [blue]Object Browser[/blue]. Where you see [blue]All Libraries[/blue], select VBA from the dropdown list. In the [blue]Classes Listing[/blue] (bottom left) select [blue]KeyCodeConstants[/blue]. All the key codes appear in the right pane.

cal.gif
See Ya! . . . . . .
 
If I read your posting right I think you want to assign your own functions to the F Keys. This is really quite simple.

First you enter the following code in your Form_load sub:

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

This causes Access to more or less constantly check to see which special keys are pressed.

Then using the following code (as an example) you can assign your code for special functions, not only to the F Keys, but to other keys as well, such as <Esc>, <UpArrow> etc.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyEscape
DoCmd.Close acForm, "YourFormName", acSaveYes
Case vbKeyUp
'Your code Up Arrow goes here
Case vbKeyDown
'Your code Down Arrow goes here
Case vbKeyF2
'Your code for F2 goes here
Case vbKeyF3
'Your code for F3 goes here
Case vbKeyF4
'Your code for F4 goes here
Case Else
End Select
End Sub

I usually DO NOT re-assign, as it were, the function for F1, which is used to bring up Access' Help Wizard.

Hope this helps you get where you're going. Sorry I was late joining the party but was out last week with an injurythat kept me away from the keyboard and just came on your post tonight!

The Missinglinq


&quot;It's got to be the going,
not the getting there that's good!&quot;
-Harry Chapin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top