D
Doc
Hey all,
I have a little piece of code I use for form navigation, and would like it
to be able to work for sub forms, as well as the main form.
I call the function with the OnClick event property, example such as
=GoToRec("Form1","Next").
When the code attempts to run from a subform, it states the the form can not
be found. Can anyone help with modifying the current code to include the
ability to navigate inside subforms?
Thanks!
Code:
Function GoToRec(frm As String, opt As String)
On Error GoTo ErrHand
If opt = "First" Then DoCmd.GoToRecord acDataForm, frm, acFirst
If opt = "Last" Then DoCmd.GoToRecord acDataForm, frm, acLast
If opt = "Next" Then DoCmd.GoToRecord acDataForm, frm, acNext
If opt = "New" Then DoCmd.GoToRecord acDataForm, frm, acNewRec
If opt = "Prev" Then DoCmd.GoToRecord acDataForm, frm, acPrevious
Exit Function
ErrHand:
Select Case Err.Number
Case 2105
Exit Function
Case Else
ErrorLog "MDSSFunc", "GoToRec", "eMf-215",
Screen.ActiveForm.Name, Err.Number, Err.Description
End Select
End Function
I have a little piece of code I use for form navigation, and would like it
to be able to work for sub forms, as well as the main form.
I call the function with the OnClick event property, example such as
=GoToRec("Form1","Next").
When the code attempts to run from a subform, it states the the form can not
be found. Can anyone help with modifying the current code to include the
ability to navigate inside subforms?
Thanks!
Code:
Function GoToRec(frm As String, opt As String)
On Error GoTo ErrHand
If opt = "First" Then DoCmd.GoToRecord acDataForm, frm, acFirst
If opt = "Last" Then DoCmd.GoToRecord acDataForm, frm, acLast
If opt = "Next" Then DoCmd.GoToRecord acDataForm, frm, acNext
If opt = "New" Then DoCmd.GoToRecord acDataForm, frm, acNewRec
If opt = "Prev" Then DoCmd.GoToRecord acDataForm, frm, acPrevious
Exit Function
ErrHand:
Select Case Err.Number
Case 2105
Exit Function
Case Else
ErrorLog "MDSSFunc", "GoToRec", "eMf-215",
Screen.ActiveForm.Name, Err.Number, Err.Description
End Select
End Function