Pass a filter from a form to a report?

  • Thread starter Thread starter Pete
  • Start date Start date
P

Pete

I have a db with a form that has a command button on it. What I'd like to
do is click on one of the fields in the form and then 'filter by selection'
or 'filter by form' followed by clicking on the button to launch a report
based on the same table as the form but passing the filter from the form to
the report. Anyone who can point me in the right direction?
 
You can try something like:

Dim strWhere as String
strWhere = Me.Filter
DoCmd.OpenReport "rptYourReport", acViewPreview, , strWhere
 
Thanks, Duane

That worked great.
Only problem is that in the report, the display of the selected value is
blank if it is in the detail section - comes thru fine if it's in the column
heading section. Guess I'll have to dig into the report to find out about
that. The filtering function works fine in the report though.

Much thanks
 
You lost me on the "display of the selected value". You asked for a filter,
you got a filter. Is there something else that you expected/needed to
happen?
 
Sorry for the confusion,

The filter does indeed work as desired - selects all records in the table
that have a value matching that in the form, and displays them in the
report.

The problem I'm having is that on the report I have combo boxes for 3 of the
fields in the table that represent values stored in other tables; one for
size, variety, & vendor. When I run the report unfiltered, the results are
as expected. When I pass a filter to the report from the form, whichever
field was selected in the form's 'filter by selection' comes up with a blank
in that field only. All the right records are there but with blanks in the
selection field.

The report has a grouping based on size with a combo box in the grouping
header and one in the grouping footer to list the size along with column
headings for several fields in the detail section. In the form, if I select
the size field and 'filter by selection', the value in the size field shows
up in each of the grouping headers and footers as expected, but if I 'filter
by selection' on any of the combo box represented fields in the detail
section of the report, the value in that column is blank - even though all
the other information for each record is shown on that line.
This only happens in the fields which are represented by combo boxes and
only in the detail section of the report. Fields where values are entered
manually in textboxes have no problem, so I assume it has something to do
with the lookup function of the combo boxes, but haven't figured out what or
why the filter selection field is the only one affected and why it doesn't
affect the size field (also a combo box) in the grouping header and footer
of the report even when it is the filter selection field. When I move this
field(& combo box) to the detail section it (mis)behaves the same as the
others.
 
There's an article 'Q208529' for filtering reports using a form. Take a look at it. Just type in the article number I wrote down in Microsoft's search engine
Chieko
 
So, what is your question?



--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Chieko Kuroda said:
There's an article 'Q208529' for filtering reports using a form. Take a
look at it. Just type in the article number I wrote down in Microsoft's
search engine.
 
Back
Top