I found a solution to this using a Public Function...here's what I have:
Code:
Public Function ChangeForm(Visible As Boolean)
'--Set visible status of checklist
[Forms]![frmInclusionExclusion]![fmeExclusion].Visible = Visible
[Forms]![frmInclusionExclusion]![lblExclusion].Visible = Visible
[Forms]![frmInclusionExclusion]![lblPregnant].Visible = Visible
[Forms]![frmInclusionExclusion]![lblBothStrategies].Visible = Visible
[Forms]![frmInclusionExclusion]![lblChronicHD].Visible = Visible
[Forms]![frmInclusionExclusion]![lblDialysis48Hrs].Visible = Visible
[Forms]![frmInclusionExclusion]![lblBaselineSCr2].Visible = Visible
[Forms]![frmInclusionExclusion]![chkPregnant].Visible = Visible
[Forms]![frmInclusionExclusion]![chkBothStrategies].Visible = Visible
[Forms]![frmInclusionExclusion]![chkChronicHD].Visible = Visible
[Forms]![frmInclusionExclusion]![chkDialysis48Hrs].Visible = Visible
[Forms]![frmInclusionExclusion]![chkBaselineSCr2].Visible = Visible
'--Update command buttons
[Forms]![frmInclusionExclusion]![cmdCheckInclusion].Enabled = Not Visible
[Forms]![frmInclusionExclusion]![cmdDone].Enabled = Visible
End Function
Code:
Private Sub cmdCheckInclusion_Click()
Dim vbAnswer As String
'--Verify that DOB and Therapy Length have not been changed
Me.txtDOB.SetFocus
Me.txtTherapyLength.SetFocus
Me.txtAdmitDate.SetFocus
'--Verify that AdmitDate, DOB and TherapyLength are not null; prompt to enter data if so
If Not IsNull(Me.txtDOB) And Not IsNull(Me.txtTherapyLength) And Not IsNull(Me.txtAdmitDate) Then
'--Check if patient meets inclusion criteria
If Me.iAdult = True And Me.iZosyn48Hrs = True Then
lblInstructions.ForeColor = RGB(34, 139, 34)
lblInstructions.Caption = "Patient " & Me.PatientID & " has met inclusion criteria. Please address the exclusion criteria in order. If you check any of the exclusion criteria, stop entering data (DO NOT check more than one). Click 'Done' when finished."
ElseIf Me.iAdult = False Or Me.iZosyn48Hrs = False Then
'--Patient does not meet inclusion criteria; prompt to enter new patient or verify data
If Me.iAdult = False And Me.iZosyn48Hrs = False Then
vbAnswer = MsgBox("Patient " & Me.PatientID & " has not met inclusion criteria (<18 years old and <48 hours of Zosyn therapy). Add another patient? (Click 'Cancel' to go back and verify the entered data)", vbYesNoCancel)
ElseIf Me.iAdult = False Then
vbAnswer = MsgBox("Patient " & Me.PatientID & " has not met inclusion criteria (<18 years old). Add another patient? (Click 'Cancel' to go back and verify the entered data)", vbYesNoCancel)
ElseIf Me.iZosyn48Hrs = False Then
vbAnswer = MsgBox("Patient " & Me.PatientID & " has not met inclusion criteria (<48 hours of Zosyn therapy). Add another patient? (Click 'Cancel' to go back and verify the entered data)", vbYesNoCancel)
End If
If vbAnswer = vbCancel Then
lblInstructions.ForeColor = RGB(0, 0, 128)
lblInstructions.Caption = "Please review the entered information, and click 'Done' when finished."
Else
'--Patient is not included
Me.Included = False
If vbAnswer = vbYes Then
DoCmd.GoToRecord , , acNewRec
lblInstructions.ForeColor = RGB(0, 0, 128)
lblInstructions.Caption = "Click 'Check Info' before clicking 'Done'"
ChangeForm (False)
ElseIf vbAnswer = vbNo Then
DoCmd.Close acForm, "frmInclusionExclusion"
DoCmd.OpenForm "frmOpening"
End If
End If
End If
'--Set visible status of exclusion criteria checklist
If Not IsNull(Me.iAdult) And Not IsNull(Me.iZosyn48Hrs) Then
ChangeForm (Me.iAdult And Me.iZosyn48Hrs)
End If
Else
lblInstructions.ForeColor = vbRed
lblInstructions.Caption = "Please make sure that data entry is complete. Click 'Check Info' when finished."
End If
End Sub
It still looks a bit like spaghetti code, but not as cumbersome anymore.