Filter Form, Print Report based on Filter

  • Thread starter 2Blessed4Stress
  • Start date

2

2Blessed4Stress

I have a report where the user can filter the results on the form using
Access filter keys. I have a button on my form that prints the results of
the filter. My problem is when the user returns to the form the next time,
the report will show up blank. I'm not that good in coding but I was using
this, based on a response on here.

Private Sub cmd_Preview_Click
Dim strWhere As String
If Me. Dirty Then Me. Dirty = False 'save any edits
If Me.FilterOn Then strWhere = Me.Filter
DoCmd.OpenReport "My Report", acViewPreview, , strWhere
End Sub

I don't want the report to remember the filter after it is closed. Should I
be using something else?
 
Ad

Advertisements

R

Ray

Try changing the line:

If Me.FilterOn Then strWhere = Me.Filter

to

If Me.FilterOn Then strWhere = Me.Filter Else strWhere = "1=1"


Ray
 

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