Administrator: A checkbox that is able to be checked on the login page if certain conditions are met. It is used to define which form is opened since each form has different objects associated with them.
CaseListRS: This holds the appropriate record source string value. This points to the query that is created which holds the desired information.
StaffName: Name of the staff who is logging in.
Code:
Public Sub OpenCases(Administrator As Boolean, CaseListRS As String, StaffName As String)
CaseListRS = Replace(CaseListRS, " ", "")
If (DCount("[ChildFullName]", CaseListRS) <= 0) Then
DoCmd.OpenForm "frmCaseListEmpty", acNormal
Forms("frmCaseListEmpty").lblCaseListHeader.Caption = StaffName & "'s Case List"
Forms("frmCaseListEmpty").lblEmptyList.Caption = "NO CASES FOR " & UCase(StaffName) & "."
Forms("frmCaseListEmpty").lblEmptyList.FontSize = 28
Forms("frmCaseListEmpty").lblEmptyList.TextAlign = Center
ElseIf (Administrator = False) Then
Forms("frmCaseList").RecordSource = CaseListRS <-- Breaks here
DoCmd.OpenForm "frmCaseList"
Forms("frmCaseList").lblCaseListHeader.Caption = StaffName & "'s Case List"
Else
DoCmd.OpenForm "frmCaseList_Admin" <-- Does not break here
Forms!frmCaseList_Admin.RecordSource = CaseListRS
Forms("frmCaseList_Admin").lblCaseListHeader.Caption = StaffName & "'s Case List"
End If
End Sub
With the breaking locations, the Me.requery would not work.