?
Solved

MS Access - Capture pressed key onclick

Posted on 2016-10-05
4
Medium Priority
?
65 Views
Last Modified: 2016-10-05
I have a form with a button.  When I click the button I need to be able to tell if CRTL was pressed at the time the button was clicked.
I'm trying to add this hidden feature where holding down CRTL and clicking a button does something different than just clicking the button.

Is there a way to do that?
0
Comment
Question by:keschuster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 1000 total points
ID: 41829833
Use the mousedown event
Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Shift And acCtrlMask) Then
    MsgBox "CTRL key down and button clicked", vbInformation
Else
    MsgBox "You clicked just the button", vbInformation
End If
End Sub

Open in new window


acShiftMask The bit mask for the SHIFT key.
acCtrlMask The bit mask for the CTRL key.
acAltMask The bit mask for the ALT key.
1
 
LVL 35

Assisted Solution

by:ste5an
ste5an earned 1000 total points
ID: 41829841
Use the MouseDown or MouseUp event of the button. You can determine whether shift, alt or ctrl was pressed by evaluating the Shift parameter:

Private Sub btnYourButton_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

  Dim CtrlOnlyPressed As Boolean
  
  CtrlOnlyPressed = (Shift And acCtrlMask = acCtrlMask)

End Sub

Open in new window

0
 

Author Closing Comment

by:keschuster
ID: 41829864
thanks guys
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 41829870
Just wondering what assistance can give a comment substantially identical than the above .
Anyway glad to have helped you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 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