filter by form

  • Thread starter Thread starter Jeanne
  • Start date Start date
J

Jeanne

Using filter by form with many, many possible variables is
there a way to quickly export (user requirement) the
results to a predesigned report format?
Thanks.
 
To open a report so that it is filtered in the same way as the form, add a
command button to your form, and put this into the Click event procedure:

Private Sub cmdPreview_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.FilterOn Then
strWhere = Me.Filter
End If

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End Sub
 
Thank you. We're almost there. The report is opening with
the code I typed into the click event proc., but it is
displaying all recording from the table, not just those
that are filtered. Suggestions?
Thanks.
 
In the DoCmd.OpenReport line, did you include the 2 commas before strWhere?
 
Yes, I did.
-----Original Message-----
In the DoCmd.OpenReport line, did you include the 2 commas before strWhere?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.





.
 
After the report is open, press Ctrl+G to open the Immediate window. Enter:
? Reports("My Report").Filter
Does this say what you expect?

Try:
? Reports("My Report").FilterOn
Does this respond with True (or -1) indicating that the filter is on?

Does kind of debugging provide you with any clues as to what is going on?
 

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

Back
Top