473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to change the RecordSource for a subReport

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
3 10641
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CSDunn | last post by:
Hello, In an Access 2003 Project that uses a SQL Server 2000 database as its data source, I am attempting to set the RecordSource property of a sub report called 'RptTeacherHistory2' that appears...
2
by: neill dumont | last post by:
I've tried to be clear, but this still seems overly complex to me, but here goes: I have a report in front of an aggregate query. I have a single subreport based on the same query for both a...
6
by: Agnes | last post by:
Please help, i had completed over 30-50 reports, now. our client insist to change the database name. anyshorcut that I can change the database name in the report without re-write all of them ??...
8
by: Maxi | last post by:
Hello, i'm sorry my bad english :( I have CR9 Webservice, how to change databadse name and User_name into Webservice method? (not Viewer Control) Tks!! -- --------------------------
1
by: Hank | last post by:
I'm using Access 2000 and want to set up the dataset for a subreport. I trying to use the Forms!SubForms scenario as a guide but I cannot get it. Here is my try: Reports!!.Report.Recordsource =...
8
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Form is: Forms!FormName..RowSource = "TableOrQueryName"
11
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
3
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RecordSource of a Master Report is: Me.RecordSource = "TableOrQueryName"
7
OuTCasT
by: OuTCasT | last post by:
I know how to change the database and sqlserver for a crystal report Dim report As New ReportDocument Dim connection As IConnectionInfo Dim oldServerName As String =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.