I would like to use PgUp and PgDown on a subform and have it move to the previous (pgup) or next(pgdown) record on the main form. I think I need to set the KeyPreview on the subform to Yes and set code on the subform on keydown event based on keycodes, but I keep running into an error on the GoToRecord command which says "The object 'frmMasterPatientVisit' isnt open." Any help on this would be helpful. It's probably something simple that I am just not getting. Here is my code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ctl As Control
Select Case KeyCode
Case vbKeyPageUp
' Process PageUp key events.
Set ctl = Forms!frmMasterTimeEntry!frmMasterPatientVisit
DoCmd.GoToControl ctl.Name
DoCmd.GoToRecord acDataForm, ctl.Name, acPrevious
Case vbKeyPageDown
' Process PageDown key events.
Case Else
End Select
End Sub
Linda in MN
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ctl As Control
Select Case KeyCode
Case vbKeyPageUp
' Process PageUp key events.
Set ctl = Forms!frmMasterTimeEntry!frmMasterPatientVisit
DoCmd.GoToControl ctl.Name
DoCmd.GoToRecord acDataForm, ctl.Name, acPrevious
Case vbKeyPageDown
' Process PageDown key events.
Case Else
End Select
End Sub
Linda in MN