Changing Recordsource Property in subreport

C

Crossh

I am trying to set the Recordsource property of a subreport in the
Report_open event. This subreport is called from another subreport that is
called from a report . I get this error.

Runtime error '2191':
You can't set the Recordsource property in print preview or after printing
has started.

I can only get this to work if I set the Recordsource property for a
subreport that's called directly from a report. Any suggestions?
 
M

Marshall Barton

Crossh said:
I am trying to set the Recordsource property of a subreport in the
Report_open event. This subreport is called from another subreport that is
called from a report . I get this error.

Runtime error '2191':
You can't set the Recordsource property in print preview or after printing
has started.

I can only get this to work if I set the Recordsource property for a
subreport that's called directly from a report. Any suggestions?


Are you sure that you really need to set the RecordSource?

If you can not find another way (Link Master/Child?), then
you should set the record source in each subreport's Open
event. The big restriction and tricky part of this is that
you can only set it the first time the open event fires:

Sub Report_Open(
Static Initialized As Boolean
If Not Initialized Then'
Me.RecordSource = whatever
Initialized = True
End If
 
C

Crossh

Are you sure that you really need to set the RecordSource?I guess I should've metioned that I'm using pass-through queries to sql
server which are being set in code. (Sorry, I'm new at this). If I have a
pass-through query for the main report recordsource, and I use the Link
Master/Child, will this only process the needed records, or will the jet
engine have to get all the records and then filter out what's needed. I want
sql to do all the processing, not access. I'm looking for better performance.
 
M

Marshall Barton

Crossh said:
I guess I should've metioned that I'm using pass-through queries to sql
server which are being set in code. (Sorry, I'm new at this). If I have a
pass-through query for the main report recordsource, and I use the Link
Master/Child, will this only process the needed records, or will the jet
engine have to get all the records and then filter out what's needed. I want
sql to do all the processing, not access. I'm looking for better performance.


If you had mentioned that, I would not have wasted your time
trying to help on a subject where I have no experience.

You should rephrase your question and start a new thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top