Print Filter Not Working

D

Doctor

I have a company form and table and a contacts form and table. I used this
code to filter my companies for printing reports. It filters great. THEN when
I went to use this code for the same operation for my Contacts, if either
case 1 or case 3 is selected, I get my report's NoData message telling me
that no data was generated for the report. (Case 2 has no filter, it prints
all records: this one, of course works fine)

What am I doing wrong, what have I missed?

Thanks in advance,


Private Sub cmdPrint_Click()
Dim strWhere As String
' Open the report based on the option chosen
' First, set up any potential filter
Select Case Me.optFilterType
' Current record only
Case 1
' Special IS NULL test in case we're printing labels on a
partial page
strWhere = "(ContactID = " & Forms!Contacts!ContactID & ") OR
(ContactID IS NULL)"
Case 3
If Not IsNothing(Forms!Contacts.Filter) Then
' Special IS NULL test in case we're printing labels on a
partial page
strWhere = "(" & Forms!Contacts.Filter & ") OR (ContactID IS
NULL)"
End If
End Select
If IsNothing(strWhere) Then strWhere = "1 = 1"
Me.Visible = False
On Error Resume Next
Select Case Me.optReportType
Case 1
DoCmd.OpenReport "rptContactsLabels5160", acViewPreview, ,
strWhere
Exit Sub
Case 2
DoCmd.OpenReport "rptContactsLabels5163", acViewPreview, ,
strWhere
' Exit - the report will close me after done with my parameter
combo
Exit Sub
Case 3
DoCmd.OpenReport "rptContactsEnvelopes", acViewPreview, , strWhere
Case 4
DoCmd.OpenReport "rptContacts", acViewPreview, , strWhere
Case 5
DoCmd.OpenReport "rptChurchContacts", acViewPreview, , strWhere
End Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top