Code:
' ******************************************************************************
' Filters the form frmLessonCard based on filter criteria in form frmLCFilter.
' ******************************************************************************
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorHandler
'DoCmd.MoveSize Parameters ([Right], [Down], [Width], [Height])
DoCmd.MoveSize 2# * 1440, 1# * 1440, 9.9 * 1440, 7.9 * 1440
'User selects all Divisions and all lesson cards
If Forms!frmLCFilter.cboDivSelect = 0 And Forms!frmLCFilter.opnStatus = 1 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter;"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter ORDER BY qryLCFilter.LNumber;"
Else
'User selects all Divisions and only the ACTIVE Lesson Cards
If Forms!frmLCFilter.cboDivSelect = 0 And Forms!frmLCFilter.opnStatus = 2 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE Inactive = False"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE Inactive = False ORDER BY LNumber;"
Else
'User selects all Divisions and only the INACTIVE Lesson Cards
If Forms!frmLCFilter.cboDivSelect = 0 And Forms!frmLCFilter.opnStatus = 3 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE Inactive = True"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE Inactive = True ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and all Lesson Cards for the FALL SEMESTER
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 1 And Forms!frmLCFilter.opnSemester = 1 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " And OFECSemester = 1"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " And OFECSemester = 1 ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and only the ACTIVE Lesson Cards for the FALL SEMESTER
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 2 And Forms!frmLCFilter.opnSemester = 1 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = False And OFECSemester = 1"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = False And OFECSemester = 1 ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and only the INACTIVE Lesson Cards for the FALL SEMESTER
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 3 And Forms!frmLCFilter.opnSemester = 1 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = True And OFECSemester = 1"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = True And OFECSemester = 1 ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and all Lesson Cards for the SPRING SEMESTER
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 1 And Forms!frmLCFilter.opnSemester = 2 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " And OFECSemester = 2"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " And OFECSemester = 2 ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and only the ACTIVE Lesson Cards for the SPRING SEMESTER
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 2 And Forms!frmLCFilter.opnSemester = 2 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = False And OFECSemester = 2"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = False And OFECSemester = 2 ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and only the INACTIVE Lesson Cards for the SPRING SEMESTER
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 3 And Forms!frmLCFilter.opnSemester = 2 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = True And OFECSemester = 2"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = True And OFECSemester = 2 ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and all Lesson Cards for ALL SEMESTERS
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 1 And Forms!frmLCFilter.opnSemester = 3 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & ""
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and only the ACTIVE Lesson Cards for ALL SEMESTERS
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 2 And Forms!frmLCFilter.opnSemester = 3 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = False"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = False ORDER BY LNumber;"
Else
'User select a specific Sub-course within the MOS Training Division and only the INACTIVE Lesson Cards for ALL SEMESTERS
If Forms!frmLCFilter.cboDivSelect = 6 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 3 And Forms!frmLCFilter.opnSemester = 3 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = True"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = True ORDER BY LNumber;"
Else
'User selects all Sub-Courses within a specific Division and all Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And IsNull(Forms!frmLCFilter.cboSubSelect) And Forms!frmLCFilter.opnStatus = 1 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & ""
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " ORDER BY LNumber;"
Else
'User selects all Sub-Courses within a specific Division and only the ACTIVE Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And IsNull(Forms!frmLCFilter.cboSubSelect) And Forms!frmLCFilter.opnStatus = 2 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " AND Inactive = False"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " AND Inactive = False ORDER BY LNumber;"
Else
'User selects all Sub-Courses within a specific Division and only the INACTIVE Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And IsNull(Forms!frmLCFilter.cboSubSelect) And Forms!frmLCFilter.opnStatus = 3 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " AND Inactive = True"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " AND Inactive = True ORDER BY LNumber;"
Else
'User selects all Sub-Courses within a specific Division and all Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And Forms!frmLCFilter.cboSubSelect = 0 And Forms!frmLCFilter.opnStatus = 1 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & ""
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " ORDER BY LNumber;"
Else
'User selects all Sub-Courses within a specific Division and only the ACTIVE Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And Forms!frmLCFilter.cboSubSelect = 0 And Forms!frmLCFilter.opnStatus = 2 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " AND Inactive = False"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " AND Inactive = False ORDER BY LNumber;"
Else
'User selects all Sub-Courses within a specific Division and only the INACTIVE Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And Forms!frmLCFilter.cboSubSelect = 0 And Forms!frmLCFilter.opnStatus = 3 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " AND Inactive = True"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LDivision = " & Forms!frmLCFilter.cboDivSelect & " AND Inactive = True ORDER BY LNumber;"
Else
'User select a specific Sub-course within a specific Division and all Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 1 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & ""
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " ORDER BY LNumber;"
Else
'User select a specific Sub-course within a specific Division and only the ACTIVE Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 2 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = False"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = False ORDER BY LNumber;"
Else
'User select a specific Sub-course within a specific Division and only the INACTIVE Lesson Cards
If Forms!frmLCFilter.cboDivSelect > 0 And Forms!frmLCFilter.cboSubSelect > 0 And Forms!frmLCFilter.opnStatus = 3 Then
Me.RecordSource = "SELECT qryLCFilter.* FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = True"
Me.lblLessonList.RowSource = "SELECT qryLCFilter.LID, qryLCFilter.LNumber, qryLCFilter.LTitle FROM qryLCFilter WHERE LVolume = " & Forms!frmLCFilter.cboSubSelect & " AND Inactive = True ORDER BY LNumber;"
Else
'User selects all OFEC lesson cards
If Me.LDivision = 6 Then
Me.OFECSemester.Visible = True
Me.NonOFECObjLabel.Visible = False
Me.sfrmLCOFECStandardsLabel.Visible = True
Me.sfrmLCOFECStandards.Visible = True
Me.MiscOFECEdObjLabel.Visible = True
Me.MiscOFECEdObj.Visible = True
Me.sfrmLCLearnOutLabel.Visible = False
Me.sfrmLCLearnOut.Visible = False
Me.sfrmLCEdObjLabel.Visible = False
Me.sfrmLCEdObj.Visible = False
Else
Me.OFECSemester.Visible = False
Me.NonOFECObjLabel.Visible = True
Me.sfrmLCOFECStandardsLabel.Visible = False
Me.sfrmLCOFECStandards.Visible = False
Me.MiscOFECEdObjLabel.Visible = False
Me.MiscOFECEdObj.Visible = False
Me.sfrmLCLearnOutLabel.Visible = True
Me.sfrmLCLearnOut.Visible = True
Me.sfrmLCEdObjLabel.Visible = True
Me.sfrmLCEdObj.Visible = True
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Exit_ErrorHandler:
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 2501
'The open form action was cancelled - ignore it - Do Nothing
Case 2450
'The form frmHiddenLogon is not open - ignore it - Do Nothing
Case Else
Call ErrorLog(Err.Number, Err.Description, Me.Name)
Resume Exit_ErrorHandler
End Select
End Sub
So if you have made it this far tell me what you think.