Option Compare Database


Private Sub PMCSbyWatch_Click()
On Error GoTo Err_PMCSbyWatch_Click
Dim intInt As Integer
Dim strRepName, strInterval, strDep, strWatch, strSQL, strQuery As String

strRepName = "PMCS: SELECT: PMCS WORKSHEET BY WATCH"

intInt = 0
strSQL = "(("
strQuery = "PMCS: SELECT: PMCS WORSHEET BY WATCH"

If chkWeekly.Value = False And chkMonthly.Value = False And chkQuarterly.Value = False And chkSemiAn.Value = False And chkAnnual.Value = False Then
    MsgBox "You Must Select an Interval"
    Exit Sub
End If
If chkWeekly.Value = True Then
    strSQL = strSQL & "(PMCS.INTERVAL)=""Weekly"""
    intInt = intInt + 1
End If

If chkMonthly.Value = True Then
    If intInt > 0 Then
        strSQL = strSQL & " Or "
    End If
    strSQL = strSQL & "(PMCS.INTERVAL)=""Monthly"""
    intInt = intInt + 1
End If

If chkQuarterly.Value = True Then
    If intInt > 0 Then
        strSQL = strSQL & " Or "
    End If
    strSQL = strSQL & "(PMCS.INTERVAL)=""Quarterly"""
    intInt = intInt + 1
End If

If chkSemiAn.Value = True Then
    If intInt > 0 Then
        strSQL = strSQL & " Or "
    End If
    strSQL = strSQL & "(PMCS.INTERVAL)=""Semi Annual"""
    intInt = intInt + 1
End If

If chkAnnual.Value = True Then
    If intInt > 0 Then
        strSQL = strSQL & " Or "
    End If
    strSQL = strSQL & "(PMCS.INTERVAL)=""Annual"""
End If

strSQL = strSQL & ") AND ((PMCS.DEPT)="""

cmbDep.SetFocus
strSQL = strSQL & cmbDep.Text & """)"

cmbWatch.SetFocus
If cmbWatch.Text = "All" Or cmbWatch.Text = "" Then
Else
strSQL = strSQL & " AND ((PMCS.WATCH)=" & cmbWatch.Text & ")"
End If

If chkDue.Value = True Then
    strSQL = strSQL & " AND (([DATE COMPLETED]+[PMCS: Interval].[INTERVAL IN DAYS])<Date()+"
    cmbDays.SetFocus
    If cmbDays.Text = "" Then
        cmbDays.Text = "0"
    End If
    strSQL = strSQL & cmbDays.Text & "))"
Else
    strSQL = strSQL & ")"
End If

PMCSbyWatch.SetFocus
'For view param options are: acViewDesign, acViewNormal (which prints the report),
'and acViewPreview
DoCmd.OpenReport strRepName, acViewPreview, strQuery, strSQL

Exit_PMCSbyWatch_Click:
    Exit Sub

Err_PMCSbyWatch_Click:
    MsgBox Error$
    Resume Exit_PMCSbyWatch_Click


End Sub