Printing filtered reports?

Lejano08

Registered User.
Local time
Today, 04:50
Joined
Jul 2, 2015
Messages
32
Hello.
I have a database with some reports that show all records in a table. Some users want to only see certain rows, so they use filter option (clicking in the field, and using the funnel symbol feature at the top.
I have a print button, but I had only set it to print the report name. So when a user filters a report and clicks print, it still prints every record, instead of the filtered results that they have set.

How can I alter my VBA code for printing so that the button prints whatever results are shown?
I don't quite understand how Me.Filter works, so every change I try still prints everything.

Right now its just back to

Private Sub btnPrint_Click()
DoCmd.OpenReport "ALL REQUESTS", acNormal
End Sub
 
The form that calls the report, must use the form controls as a filter in the where clause.

docmd.OpenReport rpt,acViewPreview,,"[state]='" & me.cboState & "'"
 
So I would need to do this for all fields?
 
The form that calls the report, must use the form controls as a filter in the where clause.

docmd.OpenReport rpt,acViewPreview,,"[state]='" & me.cboState & "'"

It is not really an input form that calls a report. Its the navigation form where you can display diff reports/forms by just clicking the button of the form you want to see. Once you click the name of the report, the report shows. They filter by using the toolbar at the top.
 
then you need to modify the form to do filtering.
If youre going to filter on multiple controls, then you must have code to determine...

You cant use form boxes in a query if there's nothing in them..so..
Test all controls for a possible filter then build the where clause.

Code:
if not isnull(cboState) then   sWhere = sWhere & " and [state]='" & cboState & "'"
if not IsNull(txtName) then    sWhere = sWhere & " and [Name]='" & txtName & "'"
if not IsNull(chkContact) then sWhere = sWhere & " and [Contact]=" & chkContact.value

    'remove 1st And
sWhere= mid(sWhere,5)
docmd.openreport  "report",,swhere
 
So there is no way to just print based off of what the user has filtered on the report?
Something like

If Me.Filter on Then....

Because they aren't really filtering the form per se, just the report that is in form view...
 
No, there isn't because you are not using a Filter on the Form, your Users are just on a record.
 

Users who are viewing this thread

Back
Top Bottom