Trying to use the filter on the form to filter report

  • Thread starter Russ via AccessMonster.com
  • Start date
R

Russ via AccessMonster.com

Setup = main form with subform as datasheet, applying filter to the datasheet
and need report which is based on the same query to open up with filtered
information of the subform. What am I doing wrong?

trying to use the code;

If Me.FilterOn Then 'Use the same filter, if it's switched on.
strWhere = Me.Filter
End If
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

but me.filter keeps getting the result of ""
 
R

Rick Brandt

Russ said:
Setup = main form with subform as datasheet, applying filter to the
datasheet and need report which is based on the same query to open up
with filtered information of the subform. What am I doing wrong?

trying to use the code;

If Me.FilterOn Then 'Use the same filter, if it's switched on.
strWhere = Me.Filter
End If
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

but me.filter keeps getting the result of ""

Where is the code running? If it is running in the main form's module then
that is the problem. The subform has the filter, not the main form. You
need something like...

If Me.SubformControlName.Form.FilterOn Then 'Use the same filter, if it's
switched on.
strWhere = Me.SubformControlName.Form.Filter
End If

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
 
R

Russ via AccessMonster.com

Thank you, that did the trick! But encountered new problem, some combo boxes
this will not work on. If I filter on a couple of combo boxes then run the
code it brings up an enter parameter value box, what would be the difference?


Rick said:
Setup = main form with subform as datasheet, applying filter to the
datasheet and need report which is based on the same query to open up
[quoted text clipped - 8 lines]
but me.filter keeps getting the result of ""

Where is the code running? If it is running in the main form's module then
that is the problem. The subform has the filter, not the main form. You
need something like...

If Me.SubformControlName.Form.FilterOn Then 'Use the same filter, if it's
switched on.
strWhere = Me.SubformControlName.Form.Filter
End If

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
 
R

Rick Brandt

Russ via AccessMonster.com said:
Thank you, that did the trick! But encountered new problem, some combo boxes
this will not work on. If I filter on a couple of combo boxes then run the
code it brings up an enter parameter value box, what would be the difference?

Many ComboBoxes show one value while containing another. Form filters might be
able to figure that out whereas your report probably can't.
 

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