Solved

MS Access - Capture pressed key onclick

Posted on 2016-10-05
4
21 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
  • 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 32

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

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

18 Experts available now in Live!

Get 1:1 Help Now