Setting a reports record source in VB

GaelicFatboy

Registered User.
Local time
Today, 17:54
Joined
Apr 17, 2007
Messages
100
Hi All,

I've got a report where I want to set the record source to one of six queries using code when I click a command button, and then fire up its print preview. The problem is the code keeps throwing up an error message saying I cannot change the record source once I've loaded the report for printing, but if I try to define the record source prior to loading the report another error is generated telling me to load the report first.

Is it possible to set the record source for a report then fire up the print preview all using VB and from a single kick of a command button.

Cheers for any help.

D
 
Yes, but I think the place to do it is the Open event of the report. I don't think it will work from outside the report, unless you put it in design view. Depending on version, you can pass the desired source in OpenArgs.
 
Cheers Paul,

That's all working fine now, it'd love to now the event call sequence for each object I was using the load event instead of the open event.

Thanks

D
 
Happy to help. The open event fires before the load event, and I think the load event is too late (data is already populating controls).
 

Users who are viewing this thread

Back
Top Bottom