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!

Trouble assigning report to variable

Status
Not open for further replies.

Mugs321

Programmer
Jan 31, 2007
49
CA
Hello,
This should be an easy question but I cannot figure it out.

I have a Report named "missingReport". The query I want to use for the RecordSource is quite complicated and so I need to set it dynamically. When I click a button in my form, I want to set the RecordSource to mentioned query. Here's the problem (taken from the button's code):

Dim misRep As Report
Set misRep = Reports![missingReport]
.
.
.

The 'Set' statement above returns "error code 438: Object doesn't support this property or method".

I can do this no problem with a form (ie Forms![missingForm] but I cannot get around the Report problem.

Any ideas?
 
firstly, why not encapsulate the complications in a single query, and then set the recordsource to that query?

when you run this code from the form, the report itself isn't loaded, therefore you cannot assign it to a report object.

you can load the report first, or do this in the report_open event

--------------------
Procrastinate Now!
 
The query, written in SQL, contains data chosen from a comboBox. How do I include dynamic data if the query is written in 'SQL View'?

I've already tried added the needed code to the report_open Sub. The code wasn't being run when I opened the report. I even put a Debug 'Stop' in the report_open and the program didn't stop.
 
I figured out how to include the comboBox data in the query. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top