Avatar of jonsuns7
jonsuns7

asked on 

Keyboard shortcuts in Access 2007

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
Microsoft Access

Avatar of undefined
Last Comment
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
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
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo