Redefining Hotkeys

ChrisTheIntern

Registered User.
Local time
Today, 12:33
Joined
Jul 10, 2015
Messages
24
Hi guys,

I am having trouble triggering the code within the ctl+click case in this code. The code for ctl+A works fine but not for ctl+click.

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'Redefining Hotkeys
'Stop ctl+A from triggering Access hotkey for "select all records"
'Redefine ctl+A to select all text in textbox
Dim ctl As Control      'Active Control
Dim ctlType As Integer
 
If Shift = 2 Then   'ctl key
    Select Case KeyCode
        Case vbKeyA     'Case ctl+A
            Debug.Print "HI"
            Set ctl = Screen.ActiveControl
            ctlType = ctl.Properties("ControlType")
            If ctlType = acTextBox Then
            ctl.SelStart = 0
            ctl.SelLength = Len(ctl.Text)
            KeyCode = 0     'Stops Access Hotkey ctl+A that selects all records
            End If

         Case vbKeyLButton   'Case ctl+Click
            Debug.Print "If this prints, I will eat my hat"
            Set ctl = Screen.ActiveControl
            ctlType = ctl.Properties("ControlType")
            If ctlType = acListBox Then
                ctl.ListIndex = -1
                Form.Repaint
            End If
    End Select
End If
End Sub

Can anyone show me the problem here?
 
see if you have an autokeys macro defined for ctrl+A
if not, then define an autokey for ctrl+A, and run some code that does nothing. that may do what you want.


---

not sure what you mean by ctrl+click though.
 
Hi Gemma,
I Googled what autokeys macro is and it sounds like it is something I make. I have not made an autokeys macro before this. The code within the ctrl+A case works fine and it is just that it will not go into the ctrl+click case.
 
as I say, I don't know what you mean by ctrl+click

do you mean, just hitting the ctrl key on its own?
 
KeyDown is a keyboard event. To handle mouse click events, use MouseDown and MouseUp.
 
Thank you guys, it was because the code was in KeyDown as Mark stated. I should've been more specific that it was leftmouseclick.
 

Users who are viewing this thread

Back
Top Bottom