Solved

MS Access - Capture pressed key onclick

Posted on 2016-10-05
4
54 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 22

Accepted Solution

by:
Ferruccio Accalai earned 250 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 34

Assisted Solution

by:ste5an
ste5an earned 250 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 22

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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