turning on a report filter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a purchase order form with a cmd button to email the po (report) to
the vendor using the DAO sendobject method. The problem is that the report
sent isn't filterd to include only the current record. The following
corrective code doesn't work:

Dim stRpt as string
Dim rpt as object

stRpt = "purchse order"
set rpt = reports!stRpt
rpt.filteron = true

The "set rpt" statement returns the error that the report isn't open or
doesn't exist. I tried the docmd.reportOpen placed before the set Rpt
statment, but I get the same error, on the same line of code. How to defince
the report variable so that I can use the FilterOn property?

DM
 
OK, but that doesn't explain why the set statement to assign the object
variable doesn't work?

DM
 
You can not set a property on an object that does not yet
exist. The report must be opened before you set the
property.

OTOH, If the report has been opened, it starts an
asynchronous execution thread and, by the time it returns to
your form's code, it is usually too late to filter the
report's data.

Putting all that together implies, as Klatuu said, the only
reliable place you can set this kind of property is in the
report's Open event.
 
Back
Top