R
Robert Neville
I utilized some record navigation code some time ago, which worked
until I place it on a nested sub-form (don't ask). Now, I need another
alternative to passing these controls to the global function. I
thought about hard-coding it as well, yet would like to get some
suggestions before proceeding with this workaround.
I need an alternative to Screen.PreviousControl and Screen.ActiveForm.
The challenge for me involves referencing Access objects specifically
controls on a sub-form. I have tried several approaches with "Me"
without success.
Call FrmFocusSave(Me!PreviousControl)
Call FrmNavGotoNext(Me!ActiveForm)
Call FrmFocusSave(Me.PreviousControl)
Call FrmNavGotoNext(Me.ActiveForm)
MS Help and a Google Group shed little insight on my scenario. MS Help
files are very elusive if you can even find the desired topic. Could
someone explain if I need to reference the form name, object, or
control? Please leave me suggestions or links on referencing all form
objects whether implicit or explicit. E.g. requery a list box on a
subform or parent form on a separate tab control. So I could add them
to my notes.
The code below gives you an idea of the current approach. Please
remember other navigation buttons use a variation of this code. This
point is reason behind not over simplifying by choosing the
workaround.
Private Sub btnNext_Click()
Const cstrProc As String = "btnNext_Click"
On Error GoTo btnNext_Click_Err
Call FrmFocusSave(Screen.PreviousControl)
Call FrmNavGotoNext(Screen.ActiveForm)
Call FrmFocusRestore
btnNext_Click_Exit:
Exit Sub
btnNext_Click_Err:
Call ErrMsgStd(Me.Name & "." & cstrProc, Err.Number,
Err.Description, True)
Resume btnNext_Click_Exit
End Sub
Public Sub FrmNavGotoNext(rfrm As Form)
' Purpose: Goto next record in form recordset
' Arguments: rfrm:=Calling form
' Calls: FrmNavIsLast
Const cstrProc As String = "FrmNavGotoNext"
On Error GoTo FrmNavGotoNext_Err
If rfrm.mtdValidate Then ' Record is valid
If Not FrmNavIsLast(rfrm) Then
'rfrm.SetFocus ' Just to be sure
Application.RunCommand acCmdRecordsGoToNext
End If
End If
FrmNavGotoNext_Exit:
Exit Sub
FrmNavGotoNext_Err:
Call ErrMsgStd(mcstrMod & "." & cstrProc, Err.Number,
Err.Description, True)
Resume FrmNavGotoNext_Exit
End Sub
until I place it on a nested sub-form (don't ask). Now, I need another
alternative to passing these controls to the global function. I
thought about hard-coding it as well, yet would like to get some
suggestions before proceeding with this workaround.
I need an alternative to Screen.PreviousControl and Screen.ActiveForm.
The challenge for me involves referencing Access objects specifically
controls on a sub-form. I have tried several approaches with "Me"
without success.
Call FrmFocusSave(Me!PreviousControl)
Call FrmNavGotoNext(Me!ActiveForm)
Call FrmFocusSave(Me.PreviousControl)
Call FrmNavGotoNext(Me.ActiveForm)
MS Help and a Google Group shed little insight on my scenario. MS Help
files are very elusive if you can even find the desired topic. Could
someone explain if I need to reference the form name, object, or
control? Please leave me suggestions or links on referencing all form
objects whether implicit or explicit. E.g. requery a list box on a
subform or parent form on a separate tab control. So I could add them
to my notes.
The code below gives you an idea of the current approach. Please
remember other navigation buttons use a variation of this code. This
point is reason behind not over simplifying by choosing the
workaround.
Private Sub btnNext_Click()
Const cstrProc As String = "btnNext_Click"
On Error GoTo btnNext_Click_Err
Call FrmFocusSave(Screen.PreviousControl)
Call FrmNavGotoNext(Screen.ActiveForm)
Call FrmFocusRestore
btnNext_Click_Exit:
Exit Sub
btnNext_Click_Err:
Call ErrMsgStd(Me.Name & "." & cstrProc, Err.Number,
Err.Description, True)
Resume btnNext_Click_Exit
End Sub
Public Sub FrmNavGotoNext(rfrm As Form)
' Purpose: Goto next record in form recordset
' Arguments: rfrm:=Calling form
' Calls: FrmNavIsLast
Const cstrProc As String = "FrmNavGotoNext"
On Error GoTo FrmNavGotoNext_Err
If rfrm.mtdValidate Then ' Record is valid
If Not FrmNavIsLast(rfrm) Then
'rfrm.SetFocus ' Just to be sure
Application.RunCommand acCmdRecordsGoToNext
End If
End If
FrmNavGotoNext_Exit:
Exit Sub
FrmNavGotoNext_Err:
Call ErrMsgStd(mcstrMod & "." & cstrProc, Err.Number,
Err.Description, True)
Resume FrmNavGotoNext_Exit
End Sub