tfurnivall
09-05-2013, 08:38 AM
Hi!
I'm trying to find a way to use Hotkeys to manage controls on an Access form.
I have a tab (multi-page) control, and I want to be able to use Ctrl=Alt+{set of keys} to make individual pages visible or not.
So far I have enabled Key Preview for the form, and written a Keydown handler for the Form:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'MsgBox "Key pressed (1): Shift value is " & Format(Shift)
' Detect Hot-keys for the pages in the MultiPage wizard, and make them Visible or not visible
' P/D/X/S/R/H/C
If Shift = acAltMask + acShiftMask Then
MsgBox "Key pressed (2): Shift value is " & Format(Shift)
' Disable Key press processing for the form!
If KeyCode = vbkeyP Then ' Project Definition
' Can't be hidden!
ElseIf KeyCode = vbkeyD Then ' Source Definition
Me.pgSourceDefinition.Visible = Not Me.pgSourceDefinition.Visible
ElseIf KeyCode = vbkeyX Then ' Extract Phase
Me.pgExtract.Visible = Not Me.pgExtract.Visible
ElseIf KeyCode = vbkeyS Then ' Scoring Phase
Me.pgScoring.Visible = Not Me.pgScoring.Visible
ElseIf KeyCode = vbkeyR Then ' Review Phase
Me.pgReview.Visible = Not Me.pgReview.Visible
ElseIf KeyCode = vbkeyH Then ' Project History
Me.pgHistory.Visible = Not Me.pgHistory.Visible
ElseIf KeyCode = vbkeyC Then ' Project Configuration
Me.pgConfigure.Visible = Not Me.pgConfigure.Visible
Else
End If
Else
End If
End Sub
I can detect that a key has been pressed (the commented out msgbox (1)), but I can't seem to get to msgbox (2). I know that KeyDown is cumulative so I don't expect to get there until I have both keys down, and then I should e able to test KeyCode.
No Luck :(
Does anyone have any ideas?
Tony
PS Also cross posted to access Programmers UK site
I'm trying to find a way to use Hotkeys to manage controls on an Access form.
I have a tab (multi-page) control, and I want to be able to use Ctrl=Alt+{set of keys} to make individual pages visible or not.
So far I have enabled Key Preview for the form, and written a Keydown handler for the Form:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'MsgBox "Key pressed (1): Shift value is " & Format(Shift)
' Detect Hot-keys for the pages in the MultiPage wizard, and make them Visible or not visible
' P/D/X/S/R/H/C
If Shift = acAltMask + acShiftMask Then
MsgBox "Key pressed (2): Shift value is " & Format(Shift)
' Disable Key press processing for the form!
If KeyCode = vbkeyP Then ' Project Definition
' Can't be hidden!
ElseIf KeyCode = vbkeyD Then ' Source Definition
Me.pgSourceDefinition.Visible = Not Me.pgSourceDefinition.Visible
ElseIf KeyCode = vbkeyX Then ' Extract Phase
Me.pgExtract.Visible = Not Me.pgExtract.Visible
ElseIf KeyCode = vbkeyS Then ' Scoring Phase
Me.pgScoring.Visible = Not Me.pgScoring.Visible
ElseIf KeyCode = vbkeyR Then ' Review Phase
Me.pgReview.Visible = Not Me.pgReview.Visible
ElseIf KeyCode = vbkeyH Then ' Project History
Me.pgHistory.Visible = Not Me.pgHistory.Visible
ElseIf KeyCode = vbkeyC Then ' Project Configuration
Me.pgConfigure.Visible = Not Me.pgConfigure.Visible
Else
End If
Else
End If
End Sub
I can detect that a key has been pressed (the commented out msgbox (1)), but I can't seem to get to msgbox (2). I know that KeyDown is cumulative so I don't expect to get there until I have both keys down, and then I should e able to test KeyCode.
No Luck :(
Does anyone have any ideas?
Tony
PS Also cross posted to access Programmers UK site