Need a report to be filtered to results of Search form

G

Guest

I've created a search form, based on code from Allen Browne's website, which
returns a set of records based on criteria entered (or left blank) in five or
six different fields.

What is the best way to filter a report to print out the records selected by
the search form (which I would obviously open from a command button on the
search form)? do I need to filter the report with a modification of the code
that filters the search form, or is their a quicker way?
 
G

Guest

two approaches.

1- create your report so that it bases it info on a query that uses your
form search cretira as it's criteria as well.

2- using code to open your report (a report without any criteria associated
to it), you can specify criteria.

docmd.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode,
OpenArgs)

so you can pull the search specifications and use them as part of the
openreport to filter your report.

Either way, I would suggest you google the subject a bit because there are
tons of examples. If one method is more interesting to you let me know and I
can work with you to get the exact code... that you require.

Daniel
 
G

Guest

Thanks Daniel

Nice to know someone is around over the weekend to help out. Having meantime
slept on the problem myself, when I woke up this morning it came to me in a
vision that the following bit of code on the Open event of the form would do
the trick:

Private Sub Report_Open(Cancel As Integer)
Dim strWhere As String

strWhere = Form_frmSearchProposals.Filter

Me.Filter = strWhere
Me.FilterOn = True
End Sub

Works like a dream. The problem was that the search form filter criteria
(multiple criteria passed to the filter on search form) are entered in a
collection of unbound controls, so the underlying query isn't itself filtered
except by whatever happened to be entered in the unbound controls.
 

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