Set Recordsource for a subreport

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

Guest

Does anyone know how to set the recordsource for a subreport within a report?

So let's say I have Report1 as my report and subrpt1 as my subreport. Where
would I set the recordsource for subrpt1?

Thanks for any help.

Sarah
 
Sarah said:
Does anyone know how to set the recordsource for a subreport within a report?

So let's say I have Report1 as my report and subrpt1 as my subreport. Where
would I set the recordsource for subrpt1?


The **only** place that you can set a report's record source
is in its own Open event procedure. Not only that, but you
can not run the code more than once if the subreport might
appear multiple times in the print out.
 
I tried doing that, but I get an error that says cannot set property after
printing has started. So it sounds like this can't be done.

Thank you.

Sarah
 
Well, you have not explained what "this" is, but as I said
before, you can only execute the code in the subreport's
Open event once. So, if you want different instances of a
subreport to use different record source tables/queries,
then it can not be done.

However, if you want all instances of the subreport to use
the same record source, then you can use code like this in
the subreport's Open event:

Sub Report_Open(
Static Initialized As Boolean
If Not Initialized Then
Me.RecordSource = "...
Initialized = True
End If
 
Back
Top