Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Keyboard shortcuts in Access 2007

Posted on 2011-10-07
3
Medium Priority
?
373 Views
Last Modified: 2012-08-13
Hi Everyone,

I want to create two keyboard shortcuts in Access 2007.

If one keyboard combination is pressed, the word  "Unique"  is input into a column value.

If another keyboard combination is pressed, the word "Duplicate" in input into a column value.

This is fairly easy in Excel, I am hoping to do the same in Access. I would just record the action in a macro. But it appears that access has predefined actions for Macros.

Thanks,

John
0
Comment
Question by:jonsuns7
  • 3
3 Comments
 
LVL 75
ID: 36933926
Here is the general idea ...

Private Sub txtBox_KeyDown(KeyCode As Integer, Shift As Integer)

   'Here are the 7 combinations of the Shift argument ...
   'from which you can trap any combination of Shift, Control and Alt ...
   'in either the Form_KeyDown and Form_KeyUp events.
   'Also ... be SURE you have Key Preview set to Yes on the Event property sheet for the Form.

   'Shift Argument for the 7 combinations of Shift, Ctrl and Alt keys:
   '0 None
   '1 Shift Key
   '2 Ctrl Key
   '3 Shift + Ctrl Keys
   '4 Alt Key
   '5 Shift + Alt Keys
   '6 Ctrl + Alt Keys
   '7 Shift + Ctrl + Alt Keys
   '----------------------------------------
   
    If Shift = 4 Then
        If KeyCode = vbKeyU Then Me.txtBox = "Unique"
    End If
       
End Sub

mx
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 36933932
For you two cases:

Private Sub txtBox_KeyDown(KeyCode As Integer, Shift As Integer)

   
    If Shift = 4 Then
        If KeyCode = vbKeyU Then Me.txtBox = "Unique": Exit Sub
    End If
   
    If Shift = 4 Then
        If KeyCode = vbKeyD Then Me.txtBox = "Dupicate": Exit Sub
    End If
   
End Sub


mx
0
 
LVL 75
ID: 36934185
So ... in the example above ...

Alt+U will enter Unique in the text box,
Alt+D will enter Duplicate in the text box.

You can actually many different shortcuts using a combination of Alt, Shift & Control ... simply by changing the Shift number in the If/Then statements.

mx
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question