kentwoodjean
Technical User
I have a report that is designed to list the specific projects employees work on that meet the query criteria of project numbers 901, 902, 704, 708. Just doing this runs the report correctly. This, however, is not how I get to the report. From the switchboard, the user selects the report button. As a result, a form opens with a drop down list of employees along with date fields that automatically populate with the 1st and last dates the employee worked on the projects. Once the employee is selected from the form, the button "preview report" is pushed and the employee report opens. Problem is that the report output does not match the criteria requested. It pulls all the projects, not just the numbered ones indicated. Below is the class module for the "Preview Report" button from the form. If there is something I need to add to this to get my criteria, can you please advise what and where? Thanks.
"Preview Report" Button
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click
Dim stDocName As String
Dim StrWhere As String
Dim varCheck As Variant
If IsNull(Me.cboCSR) Or IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox ("You must enter all criteria"
Exit Sub
End If
varCheck = DCount("CSR", "ProjLog", "CSR = '" & Me.cboCSR & "' And " & _
"([Start Date] Between #" & Me.StartDate & "# And #" & Me.EndDate & "# Or " & _
"[End Date] Between #" & Me.StartDate & "# And #" & Me.EndDate & "#)"
If IsNull(varCheck) Then
MsgBox ("There's nothing in the report."
Exit Sub
End If
' Launch the report
stDocName = "701/901"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdReport_Click:
Exit Sub
Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click
End Sub
"Preview Report" Button
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click
Dim stDocName As String
Dim StrWhere As String
Dim varCheck As Variant
If IsNull(Me.cboCSR) Or IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox ("You must enter all criteria"
Exit Sub
End If
varCheck = DCount("CSR", "ProjLog", "CSR = '" & Me.cboCSR & "' And " & _
"([Start Date] Between #" & Me.StartDate & "# And #" & Me.EndDate & "# Or " & _
"[End Date] Between #" & Me.StartDate & "# And #" & Me.EndDate & "#)"
If IsNull(varCheck) Then
MsgBox ("There's nothing in the report."
Exit Sub
End If
' Launch the report
stDocName = "701/901"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdReport_Click:
Exit Sub
Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click
End Sub