Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS Access - Capture pressed key onclick

Posted on 2016-10-05
4
Medium Priority
?
81 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

636 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