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.
 
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?
 
Back
Top