Applying Global Filter to a Report

R

Ralph Wischnewski

This question comes up occasionally on this community, but I still can't
figure it out.

I have a global filter set up: Public gstrDirView

I have a unbound form that allows users to select criteria with the results
showing on a "View" form. I use the "gstrDirView" to filter the records and
this works just fine. After viewing the results on this view Form the users
want to print a report showing these filtered records. There is a command
button on the View Form that opens the report, and on the report's "OnOpen"
event I have the following code:

Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open_Click

If gsrtdirView <> vbNullString Then
Me.Filter = gstrDirView
Me.FilterOn = True
gstrDirView = vbNullString
End If

Exit_Report_Open_Click:
Exit Sub

Err_Report_Open_Click:
MsgBox Err.Description
Resume Exit_Report_Open_Click


End Sub

The report however continues to show all records of the undelying querry.

What am I doing wrong?

Thank you
 
O

Ofer Cohen

Use the filter on the command line of the open report

Docmd.OpenReport "ReportName" , , , gstrDirView
 

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