G
Guest
Hello,
I have some code (see following) that will lookup to a table with Form name
and a number assigned to that form to open the 'next' form in a series via a
Command Button:
Private Sub Form_Current()
Call SetAutoValues(Me)
End Sub
Private Sub Next_Click()
On Error GoTo Err_Next_Click
Call OpenNextForm(Me.Name)
Exit_Next_Click:
Exit Sub
Err_Next_Click:
DoCmd.Close acForm, Me.Name
Resume Exit_Next_Click
End Sub
Code for the Subs insside a Module that called by the above Subs:
Sub OpenNextForm(strName As String)
Dim intOrder As Integer, frmName As String
On Error GoTo OpenNextForm_Err
intOrder = DLookup("[FormOrder]", "LU_Forms", "[FormName]= '" & strName
& "'")
frmName = DLookup("[FormName]", "LU_Forms", "[FormOrder]= " & intOrder
+ 1)
If Not IsNull(frmName) Then
DoCmd.OpenForm frmName, , , , acAdd
End If
DoCmd.Close acForm, strName
OpenNextForm_Err:
'MsgBox Err.Description
Resume Next
End Sub
ALL forms in the series have the same 4 fields in the Header section of the
form. The code opens the next Form in the series beautifully, but I would
like it to auto-populate the values of those 4 header fields to the values
set in the equivalent header fields in the first form of the series. I have
the following code 'SetAutoValues' (below), but no matter how I call it, I
either get an error, or
the 4 header fields do not get auto-populated w/ no error message received
(where 'fScrEligCriteria' is the initial form and 'patient' is the unique
number assigned to the patient):
Sub SetAutoValues(frm As Form)
On Error GoTo SetAutoValues_err
' Set Automatic Values in each form in series
With frm
!studyday = Forms!fScrEligCriteria!studyday
!patient = Forms!fScrEligCriteria!patient
!pat_init = Forms!fScrEligCriteria!pat_init
!site = Forms!fScrEligCriteria!site
End With
SetAutoValues_err:
Resume Next
End Sub
Any ideas on how to BOTH navigate to next form in series and autopopulate
the 4 header fields by clicking on the Command Button would be greatly
appreciated.
I have some code (see following) that will lookup to a table with Form name
and a number assigned to that form to open the 'next' form in a series via a
Command Button:
Private Sub Form_Current()
Call SetAutoValues(Me)
End Sub
Private Sub Next_Click()
On Error GoTo Err_Next_Click
Call OpenNextForm(Me.Name)
Exit_Next_Click:
Exit Sub
Err_Next_Click:
DoCmd.Close acForm, Me.Name
Resume Exit_Next_Click
End Sub
Code for the Subs insside a Module that called by the above Subs:
Sub OpenNextForm(strName As String)
Dim intOrder As Integer, frmName As String
On Error GoTo OpenNextForm_Err
intOrder = DLookup("[FormOrder]", "LU_Forms", "[FormName]= '" & strName
& "'")
frmName = DLookup("[FormName]", "LU_Forms", "[FormOrder]= " & intOrder
+ 1)
If Not IsNull(frmName) Then
DoCmd.OpenForm frmName, , , , acAdd
End If
DoCmd.Close acForm, strName
OpenNextForm_Err:
'MsgBox Err.Description
Resume Next
End Sub
ALL forms in the series have the same 4 fields in the Header section of the
form. The code opens the next Form in the series beautifully, but I would
like it to auto-populate the values of those 4 header fields to the values
set in the equivalent header fields in the first form of the series. I have
the following code 'SetAutoValues' (below), but no matter how I call it, I
either get an error, or
the 4 header fields do not get auto-populated w/ no error message received
(where 'fScrEligCriteria' is the initial form and 'patient' is the unique
number assigned to the patient):
Sub SetAutoValues(frm As Form)
On Error GoTo SetAutoValues_err
' Set Automatic Values in each form in series
With frm
!studyday = Forms!fScrEligCriteria!studyday
!patient = Forms!fScrEligCriteria!patient
!pat_init = Forms!fScrEligCriteria!pat_init
!site = Forms!fScrEligCriteria!site
End With
SetAutoValues_err:
Resume Next
End Sub
Any ideas on how to BOTH navigate to next form in series and autopopulate
the 4 header fields by clicking on the Command Button would be greatly
appreciated.