By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,369 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,369 IT Pros & Developers. It's quick & easy.

Codes in using short cut keys in a form instead of command buttons.

P: 9
What are the example codes for the forms instead of using a command buttons.?
Mar 12 '07 #1
Share this Question
Share on Google+
7 Replies


missinglinq
Expert 2.5K+
P: 3,532
If you're asking how to set up shortcuts keys so that you don't have to click on the command buttons, you don't need any code. Just place a command button on the form and use the wizard or right the code to set its function. Goto the button's Property Box and in the Caption box enter the Caption for the button, preceding the letter that you want to use as the shortcut key with an ampersand. If the text you want on the button's is Close, then in the Caption box enter &Close. Now when you hit <Alt> + <C> it will be the same as clicking on the Close button.

Hope this helps!
Mar 12 '07 #2

P: 9
If you're asking how to set up shortcuts keys so that you don't have to click on the command buttons, you don't need any code. Just place a command button on the form and use the wizard or right the code to set its function. Goto the button's Property Box and in the Caption box enter the Caption for the button, preceding the letter that you want to use as the shortcut key with an ampersand. If the text you want on the button's is Close, then in the Caption box enter &Close. Now when you hit <Alt> + <C> it will be the same as clicking on the Close button.

Hope this helps!
thanks for the your reply to my questions.But what i mean is that how to use the short cut keys like F3,F4..Example you want that the Close Command can be executed by using a short key like F3 instead of Clicking the command button Close...thank you!!!!
Mar 12 '07 #3

P: 9
I want the codes for using short cut keys like F3,F4 etc. to execute the commands like close or in the main menu to open another form.
example is that:

PRESS F3 TO OPEN STUDENT ENTRY SCREEN
F4 TO CLOSE THE FORM

I want the codes for it...
Mar 12 '07 #4

missinglinq
Expert 2.5K+
P: 3,532
Function Keys are not shortcut keys, they're Function Keys! What you're talking about is re-assigning the use of the Function Keys. You should always consider what the native function of these keys are before changing their functions! F1, for example, pulls up Access Help, and should never be re-assigned.

Set KeyPreview to TRUE either in Form’s Property Box or as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Me.KeyPreview = True
  3. End Sub
‘Now in Form_KeyDown sub assign actions to keys
Expand|Select|Wrap|Line Numbers
  1. Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
  2.     Select Case KeyCode
  3.  
  4.     Case vbKeyF1 ‘This is Access Help and should not be re-assigned
  5.  
  6.     Case vbKeyF2 
  7.       ‘Code for F2 key here
  8.        KeyCode = 0
  9.  
  10.     Case vbKeyF3
  11.       ‘Code for F3 key here
  12.        KeyCode = 0
  13.  
  14.     Case vbKeyF4
  15.       ‘Code for F4 key here
  16.        KeyCode = 0
  17.  
  18.     Case vbKeyF5
  19.       ‘Code for F5 key here
  20.        KeyCode = 0
  21.    End Select
  22. End Sub
And so forth! You can also assign other keys in this manner, just remember to consider the "normal" function before re-assigning any key!
Mar 12 '07 #5

ADezii
Expert 5K+
P: 8,628
What are the example codes for the forms instead of using a command buttons.?
You can create an AutoKeys Macro to do virtually anything in Access simply by a single or multiple Key(s) combination(s). It involves no code, per say, but only a familiarization with various Key designators, e.g. (+ for SHIFT, ^ for CTRL, and % for ALT, {F4}, {F7}, etc.). If you need more information, please let me know.
Mar 13 '07 #6

P: 9
Thank you every body for helping me!!!!!!!!!!!!!!!!!!!For that function keys!!!!
Mar 13 '07 #7

P: 9
Function Keys are not shortcut keys, they're Function Keys! What you're talking about is re-assigning the use of the Function Keys. You should always consider what the native function of these keys are before changing their functions! F1, for example, pulls up Access Help, and should never be re-assigned.

Set KeyPreview to TRUE either in Form’s Property Box or as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Me.KeyPreview = True
  3. End Sub
‘Now in Form_KeyDown sub assign actions to keys
Expand|Select|Wrap|Line Numbers
  1. Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
  2.     Select Case KeyCode
  3.  
  4.     Case vbKeyF1 ‘This is Access Help and should not be re-assigned
  5.  
  6.     Case vbKeyF2 
  7.       ‘Code for F2 key here
  8.        KeyCode = 0
  9.  
  10.     Case vbKeyF3
  11.       ‘Code for F3 key here
  12.        KeyCode = 0
  13.  
  14.     Case vbKeyF4
  15.       ‘Code for F4 key here
  16.        KeyCode = 0
  17.  
  18.     Case vbKeyF5
  19.       ‘Code for F5 key here
  20.        KeyCode = 0
  21.    End Select
  22. End Sub
And so forth! You can also assign other keys in this manner, just remember to consider the "normal" function before re-assigning any key!
thank you very much!!!!!!!!!!!!!!!!!!!!!!!!!!youre so kind.....it helps me a lot for my program!!!!
Mar 13 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.