By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

How to change the RecordSource for a subReport

P: n/a
Dear reader,

How to change the RecordSource for a subReport.

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?

Thanks for any help.

Kind regards,

Simon
Nov 17 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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?

Nov 17 '08 #2

P: n/a
One idea might be to use the 'openargs' option as in

DoCmd.OpenReport "rptname", , , , , QueryX

then in the report open event add the code

me.recordsource = me.openargs

bobh.
On Nov 17, 2:16*pm, "Simon van Beek" <SvanBee...@Versatel.nlwrote:
Dear reader,

How to change the RecordSource for a subReport.

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?

Thanks for any help.

Kind regards,

Simon
Nov 17 '08 #3

P: n/a
Open your main report in design view. Click on the subreport box control)
that holds your subreport. Open properties, go to the Other tab and see
what the name is of the subreport box is. Let's say the name is
SimonVanBeek. Change your code to:

Reports!MainReport!SimonVanBeek.Report.SourceObjec t = "QueryX"

If you are changing the source object, most likely you need to change the
LinkMaster and LinlChild properties too!

Steve
"Simon van Beek" <Sv********@Versatel.nlwrote in message
news:49***********************@news.tele2.nl...
Dear reader,

How to change the RecordSource for a subReport.

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?

Thanks for any help.

Kind regards,

Simon


Nov 18 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.