I have a report and a subreport tied to the same query. To run the report the user selects criteria off a form and presses a button.
The problem is that the main report runs with the criteria, however, the subreport does not.
How do I fix this?
Here is the current code:
Private Sub Command54_Click()
Dim strWhere As String
Dim strwhere1 As String
Dim strwhere2 As String
If [Location] = 0 Then
MsgBox "No facility selected"
Exit Sub
End If
Select Case Me.Location
Case 1
strwhere1 = "([CC Summary 2nd Level] = 1340) OR " _
& "([CC Summary 2nd Level] > 3999 AND " _
& "[CC Summary 2nd Level] <> 9500 AND " _
& "[CC Summary 2nd Level] Not Between 7700 And 7799)"
Case 2
strwhere1 = "([CC Summary 2nd Level] In (1350, 1800, 1801, 1805, 1905, 9500)) OR " _
& "([CC Summary 2nd Level] Between 3000 and 3999) OR " _
& "([CC Summary 2nd Level] Between 7700 and 7799)"
End Select
strwhere2 = "([Attendance Code] In ('E', 'OA'))"
strWhere = "(" & strwhere1 & ")" & " AND " & "(" & strwhere2 & ")"
If DCount("*", "F - Query for Reports", strWhere) = 0 Then
MsgBox "There is no current E Code data for the choosen facility", vbInformation
Else
DoCmd.CLOSE acForm, "ReportChoices"
DoCmd.OpenReport "D - ECode", acViewPreview, , strWhere
End If
End Sub
The problem is that the main report runs with the criteria, however, the subreport does not.
How do I fix this?
Here is the current code:
Private Sub Command54_Click()
Dim strWhere As String
Dim strwhere1 As String
Dim strwhere2 As String
If [Location] = 0 Then
MsgBox "No facility selected"
Exit Sub
End If
Select Case Me.Location
Case 1
strwhere1 = "([CC Summary 2nd Level] = 1340) OR " _
& "([CC Summary 2nd Level] > 3999 AND " _
& "[CC Summary 2nd Level] <> 9500 AND " _
& "[CC Summary 2nd Level] Not Between 7700 And 7799)"
Case 2
strwhere1 = "([CC Summary 2nd Level] In (1350, 1800, 1801, 1805, 1905, 9500)) OR " _
& "([CC Summary 2nd Level] Between 3000 and 3999) OR " _
& "([CC Summary 2nd Level] Between 7700 and 7799)"
End Select
strwhere2 = "([Attendance Code] In ('E', 'OA'))"
strWhere = "(" & strwhere1 & ")" & " AND " & "(" & strwhere2 & ")"
If DCount("*", "F - Query for Reports", strWhere) = 0 Then
MsgBox "There is no current E Code data for the choosen facility", vbInformation
Else
DoCmd.CLOSE acForm, "ReportChoices"
DoCmd.OpenReport "D - ECode", acViewPreview, , strWhere
End If
End Sub