Let's start back with terminology . . . just as there is no Access object
called a Subform, there is no Access object called a Subreport. There are
Subform Controls which can appear on either a Form or a Report, and
Subreport Controls which can appear only on Reports.
Subform and Subreport Controls do not have a Record Source, they have a
Source Object... which can be a Form, Report, or Datasheet. But when you
imbed a Form or Report in a Subreport Control, as far as I know, it's Record
Source can only be changed in its Open Event.
And, I have never tried to jump through the hoops to force code in the Open
Event of a Report in a Subreport control to execute to change its Record
Source.
I would never have considered trying it in either the Format or Print event
of the Detail Section in which the Subreport Control is located... I would
have just assumed that it would not work.
If you cannot synchronize the data between the Detail and the Report in the
Subreport Control using the LinkChildFields and LinkMasterFields of the
Subreport Control, I suspect you will have to find another approach to what
you want to do...
It might be possible to create a query joining what you are using as the
Record Source of the Main Report and the Record Source of the Report in the
Subform Control, and use Sorting and Grouping, and properties (e.g.,
show/don't show duplicates) to control what is actually printed.
Access reporting is really quite flexible, all things considered... this is
my 50th year in the computer business, and I've never found a more capable,
easier-to-use report generator on mainframes, minicomputers, or
microcomputers than the one provided by Access.
Some believe SQL Server Reporting Services to be as good, or better -- but,
of course, that would require you be using some flavor of SQL Server as your
data store.
Larry Linson
Microsoft Office Access MVP
"Simon van Beek" <Sv********@Versatel.nlwrote in message
news:49***********************@news.tele2.nl...
For forms the syntaxes is:
Forms!MainForm!SubForm.Form.RecordSource = "QueryX"
But for a report the following syntaxes is not working:
Reports!MainReport!SubReport.Report.RecordSource = "QueryX"
Is there a possibility to change the RecordSource for a subReport in the
same way as for subForm?