473,287 Members | 1,927 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,287 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 10626
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 =...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.