Requery in a report

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

One of my reports needs to set a filter and
"Requery" the RecordSource accordingly.
The filter expression is obtained via a public
variable, an O2K necessity with reports, but
when I code Me.Requery after having set
the filter the Me.Requery raises an error.

I tried passing the filter expression via the
DoCmd.OpenReport Where clause, but
that doesn't seem to work, or I don't have
the syntax correct?
E.g., "FamilyDuplex = " & GrpExp

Apparently the Requery method is not
valid in reports. How do I accomplish this
task?

Thanks,
Bill
 
Using the Where clause in the DoCmd.OpenReport is the method I tend to use.
If FamilyDuplex is a text field, you need to use something like:
DoCmd.OpenReport "rptYourRpt", acPreview, _
, "FamilyDuplex = """ & GrpExp & """"
 
Thanks, I was suspicious that I didn't have the syntax
correct on the "Where" parameter to OpenReport.
I'll try that now.
Thanks again,
Bill
 
Duane,
I observe Me.Filter to be the expression that was passed
as the "Where" clause to the OpenReport. However, it's
not at all clear at what stage of processing in the report
that the value of Me.Filter is available for inspection from
code. I.e., in the OnOpen code sometimes Me.Filter is
set per the "Where" and other times it's empty.

Is there some sort of inherent delay or something like that?

Thanks,
Bill
 
I moved my "inspection" code to the OnFormat of the
ReportHeader section and consistently find the expression
that was passed as the "Where" clause.

That will solve my needs, but I still don't understand the
opening sequence and exactly at what point Me.Filter
is available to code?

Thanks,
Bill
 
The filter property will be available in any On Format or On Print event.
You can also bind the filter property to a text box like:
="Current Report Filter: " & [Filter]
 
Back
Top