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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vitaminB18
    New Member
    • Mar 2007
    • 9

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

    What are the example codes for the forms instead of using a command buttons.?
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    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!

    Comment

    • vitaminB18
      New Member
      • Mar 2007
      • 9

      #3
      Originally posted by missinglinq
      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!!!!

      Comment

      • vitaminB18
        New Member
        • Mar 2007
        • 9

        #4
        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...

        Comment

        • missinglinq
          Recognized Expert Specialist
          • Nov 2006
          • 3533

          #5
          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:

          Code:
          Private Sub Form_Load()
          	Me.KeyPreview = True
          End Sub
          ‘Now in Form_KeyDown sub assign actions to keys
          Code:
          Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
          	Select Case KeyCode
          	
          	Case vbKeyF1 ‘This is Access Help and should not be re-assigned
          	  
          	Case vbKeyF2 
          	  ‘Code for F2 key here
          	   KeyCode = 0
             
          	Case vbKeyF3
          	  ‘Code for F3 key here
          	   KeyCode = 0
          
          	Case vbKeyF4
          	  ‘Code for F4 key here
          	   KeyCode = 0
            
          	Case vbKeyF5
          	  ‘Code for F5 key here
          	   KeyCode = 0
             End Select
          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!

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            Originally posted by vitaminB18
            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.

            Comment

            • vitaminB18
              New Member
              • Mar 2007
              • 9

              #7
              Thank you every body for helping me!!!!!!!!!!!!! !!!!!!For that function keys!!!!

              Comment

              • vitaminB18
                New Member
                • Mar 2007
                • 9

                #8
                Originally posted by missinglinq
                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:

                Code:
                Private Sub Form_Load()
                	Me.KeyPreview = True
                End Sub
                ‘Now in Form_KeyDown sub assign actions to keys
                Code:
                Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
                	Select Case KeyCode
                	
                	Case vbKeyF1 ‘This is Access Help and should not be re-assigned
                	  
                	Case vbKeyF2 
                	  ‘Code for F2 key here
                	   KeyCode = 0
                   
                	Case vbKeyF3
                	  ‘Code for F3 key here
                	   KeyCode = 0
                
                	Case vbKeyF4
                	  ‘Code for F4 key here
                	   KeyCode = 0
                  
                	Case vbKeyF5
                	  ‘Code for F5 key here
                	   KeyCode = 0
                   End Select
                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!!!!

                Comment

                Working...