Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to build a filter for a report using a variable for the report nam 1

Status
Not open for further replies.

nodrog77

Programmer
Sep 26, 2007
47
AU
Hi All,

I'm currently trying to build a "universal" filter form with which to apply filters to existing reports as they are opened.

I have built the filter with no problems but I have trouble applying it to the report when using a variable for the report name rather than the actual name.

I can use:
Reports(0).FilterOn = True
Reports(0).Filter = Report_Filter

but this assumes that there is ONLY ONE report open and I don't feel entirely comformtable about that. When I try to use a variable, eg.

Calling_Report = Me.OpenArgs

Reports!Calling_Report.FilterOn = True
Reports!Calling_Report.Filter = Report_Filter

I get an error saying that the report name "Calling_Report" is misspelled or doesn't exist.

Can anybody help?
 
g'day nodrog,

Too easy mate, give this a go:

Code:
Dim rpt As Report
Dim calling_Report As String

calling_report=me.openargs
For Each rpt In Reports
    If rpt.Name = calling_report Then
        rpt.FilterOn = True
        rpt.Filter = report_filter
    End If
Next rpt

good luck,

JB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top