ClaraBarton
Registered User.
- Local time
- Today, 11:35
- Joined
- Oct 14, 2019
- Messages
- 654
I have the following code to filter the form recordsource. The records are on a subdatasheet that can also be filtered by the headers.
When I want a report of the found records the filter only returns what has been filtered by the headers
Why doesn't the filter use both conditions and how can I fix this?
Code:
Select Case Me.optSales
Case 1 'Default--All Contacts
Me!subfrmList.Form.RecordSource = "qryContacts"
Exit Sub
Case 2 'Contacts with no sales
strWhere = "[Sales] <" & 1
Case 3 'Contacts with Sales
strWhere = "[Sales] >" & 0
End Select
strSQL = "SELECT * FROM qryContacts " _
& "WHERE " & strWhere
Me!subfrmList.Form.RecordSource = strSQL
Code:
strReport = Me!lstReports
'check if report is already open and close it
DoCmd.Close acReport, strReport
Select Case strReport
Case Is = "repContacts"
If FilterOn = True Then
strWhere = Me!subfrmList.Form.Filter
Else: strWhere = ""
End If
Case Is = "repContactSales"
strWhere = Me!subfrmList.Form.Filter
Case Is = "repFollowUp"
strWhere = ""
End Select
If strReport = "repContacts" And FilterOn = True Then
strWhere = Me!subfrmList.Form.Filter
Else: strWhere = ""
End If