Hi All,
I am trying to assign function keys to perform actions on a form and sub form.
On the "frmMainClient" form I have an OnLoad event:
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
and a OnKeyDown event:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF2
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = "[account_no]=" & Me![account_no]
stDocName = "frmJobNew"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
Case vbKeyF3
Dim stDocName2 As String
Dim stLinkCriteria2 As String
stDocName2 = "frmJobEdit"
stLinkCriteria2 = "[job_no]=" & Me![job_no]
DoCmd.OpenForm stDocName2, , , stLinkCriteria2, acFormEdit
Case vbKeyF4
' Process F4 key events.
Case Else
End Select
End Sub
The "case vbKeyF2" works fine.
The "case vbKeyF3" will not work because I think the subform "frmJob" is not in focus. Can anyone give some advice on how to resolve this problem.
Kind regards
I am trying to assign function keys to perform actions on a form and sub form.
On the "frmMainClient" form I have an OnLoad event:
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
and a OnKeyDown event:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF2
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = "[account_no]=" & Me![account_no]
stDocName = "frmJobNew"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
Case vbKeyF3
Dim stDocName2 As String
Dim stLinkCriteria2 As String
stDocName2 = "frmJobEdit"
stLinkCriteria2 = "[job_no]=" & Me![job_no]
DoCmd.OpenForm stDocName2, , , stLinkCriteria2, acFormEdit
Case vbKeyF4
' Process F4 key events.
Case Else
End Select
End Sub
The "case vbKeyF2" works fine.
The "case vbKeyF3" will not work because I think the subform "frmJob" is not in focus. Can anyone give some advice on how to resolve this problem.
Kind regards