• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Finding out if the "shift" key is being held down.

Is there a way in Access 2003 to find out if the "shift" key is being held down?  When a label is double clicked, I want one thing to happen if "shift" is held down and another thing to happen if it is not being held down.
0
Declan_Basile
Asked:
Declan_Basile
1 Solution
 
fabriciofonsecaCommented:
1 - Change the form property "Key preview" to "Yes"
2 - In the event Form_KeyDown write     Debug.Print KeyCode, Shift

The KeyCode is the ASCII number of the key and shift is 0 or 1 whether pressed or not.


Regards
0
 
GRayLCommented:
Not sure I follow you.  I'm running Access 2003 and there are no events associated with a label.  How are you going to detect whether a label has been double-clicked?
0
 
Rey Obrero (Capricorn1)Commented:
Ray,
you must be looking at a label attached to a control..
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
fabriciofonsecaCommented:
Please see the attachment example with a possible solution


Regards
DoubleClickShift.mdb
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"and shift is 0 or 1 whether pressed or not."

That is not accurate. This is the drill:

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.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   
   '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
   '----------------------------------------
   
End Sub

0
 
GRayLCommented:
Rey:  That'll do it every time!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now