Printing Filters in a form

MaxEklund

New member
Local time
Today, 03:08
Joined
Oct 20, 2006
Messages
3
Having trouble printing after I performed a filter. Have a subform with continuous forms that I put various filters on..., however when printing, all the records print and not just what was filtered...Is there a way around this. Basically, I would like to be able to print out only the filtered records in my form view.

Max
 
Last edited:
Why are you not using a query to filter the records and printing a report based on the query?
 
The filter for the form does not automatically transfer to a report. You will neet to use the same filter for your report
(example)
Open your report
Set your filter
Turn filter on

Or

Pass the filter on when opening the report.
 
Last edited:
Report queries

Yah...I normally would just create a report and change the queries...I just have an engineer that prefers to print from Forms. Is it possible to print filtered data from Forms?:confused:
 
I've been working to solve the exact same problem in my own project, and I BELIEVE that this code will do what you want (although it may not be very efficient). Unfortunately it does NOT work in my case as I'm using a .ADP project (Access front-end with SQLServer back-end).

Good luck, please let us know how it goes for you, and if ANYONE knows how to make a Report show only the user-filtered records from a form in an ADP project, PLEASE PLEASE PLEASE post a solution -- I'm desperate -- thanks.

Try the following VBA code in your print-button's click event handler, which I've read should work in plain Access (but fails for me because I'm using SQL Server at the back-end) -- you should only need to change the string "myreport" to your report name.

Code:
        Dim strWhere As String
        strWhere = ""
        If Me.Dirty Then
            Me.Dirty = False
        End If
        If Me.FilterOn Then
            strWhere = Me.Filter
        End If
        DoCmd.OpenReport "myreport", acPreview, , strWhere

-radio1
 
Are you sure this works. I didn't think you could set the forms dirty property. just test it.

to save a dirty record, you want runcommand accmdrecordsave, I think
 
gemma-the-husky said:
Are you sure this works. I didn't think you could set the forms dirty property. just test it.

to save a dirty record, you want runcommand accmdrecordsave, I think

THAT part (Me.Dirty = False) works okay for me -- I'm using Access 2002, with SQLServer 2000 (MSDE actually) on the back-end.

The code only fails later on for me with SQL syntax errors because the form's Me.Filter returns a 'where' clause in Access/Jet's SQL syntax, not SQLServer's T-SQL syntax.

-radio1
 
You will probably need to save the record first, if it has been changed, for any updates to be shown on the report.
 

Users who are viewing this thread

Back
Top Bottom