Solved

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

Posted on 2008-10-23
6
316 Views
Last Modified: 2013-11-27
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
Comment
Question by:Declan_Basile
6 Comments
 
LVL 8

Accepted Solution

by:
fabriciofonseca earned 500 total points
Comment Utility
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
 
LVL 44

Expert Comment

by:GRayL
Comment Utility
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
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
Ray,
you must be looking at a label attached to a control..
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Expert Comment

by:fabriciofonseca
Comment Utility
Please see the attachment example with a possible solution


Regards
DoubleClickShift.mdb
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
"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
 
LVL 44

Expert Comment

by:GRayL
Comment Utility
Rey:  That'll do it every time!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now