473,396 Members | 1,966 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,396 software developers and data experts.

How to change the RecordSource in a SubReport

Dear reader,

The syntax for the VBA code to change the RecordSource of a Master Report
is:

Me.RecordSource = "TableOrQueryName"

But now the syntax to change the RecordSource of a SubReport:

I think it has to be something like this:

Reports.MasterReportName.SubReportName.RecordSourc e =
"TableOrQueryName"

But this is not working.

Is there a working syntax for this?

Tanks for any help.

Kind regards,

Simon

Jun 27 '08 #1
3 9348
You are aware, I presume, that there is no Access "Subreport" object. There
is a Subreport Control, into which either a Report or a Form can be
imbedded. Code in a module or event of the parent Reportwould address the
RecordSource of a Report or Form embedded into a Subreport Control is as
follows:

Reports!<yourreportname>!<subreportcontrolname>.Re port.RecordSource

Reports!<yourreportname>!<subreportcontrolname>.Fo rm.RecordSource

Me!<subreportcontrolname>.Report.RecordSource

OR

Me!<subreportcontrolname>.Form.RecordSource

But that would likely only add to your frustration, because at runtime you
can only change the RecordSource of a Report in that Report's own Open
event. Thus you'd need to put the code in the Open event of the Report/Form
embedded in the Subreport Control, as:

Me.RecordSource = whateveryouwanttosetitto

In a well-designed, well-implemented Access database it is so rare that
you'd need to change the RecordSource of a Report/Form embedded in a
Subreport Control, that I am obliged to ask you just what you are trying to
accomplish by doing so. It's entirely possible that someone can offer a
useful suggestion for accomplishing the same purpose in a different way.

Generally, Subform and Subreport controls are used for displaying
information related to the Information currently displayed in their parent
form or Report, and use the LinkMasterFields and LinkChildFields properties
of the Subform or Subreport Controls to synchronize them.

Note that I don't rule out that you have encoutered an exception, and really
do need to do what you are trying to do... but generally, in the past, when
this has been asked, what's needed is not to change the RecordSource, but to
change the layout/design of the data tables themselves.

Larry Linson
Microsoft Office Access MVP
"Simon" <Sv********@Versatel.nlwrote in message
news:48***********************@news.tele2.nl...
Dear reader,

The syntax for the VBA code to change the RecordSource of a Master Report
is:

Me.RecordSource = "TableOrQueryName"

But now the syntax to change the RecordSource of a SubReport:

I think it has to be something like this:

Reports.MasterReportName.SubReportName.RecordSourc e =
"TableOrQueryName"

But this is not working.

Is there a working syntax for this?

Tanks for any help.

Kind regards,

Simon

Jun 27 '08 #2
Lary,

My SubReport is synchronized with a LinkMasterField and LinkChildField.
If I put in the Open event of the SubReport

Me.RecordSource = "QueryName"

an error pups up. It seems to be the SubReport on open event will be
activated after each record in the MasterReport. So an error pups up with
the massage "You can't change the RecordSource after the report is already
open".

Do you have a sugestion how to manage that.
Thanks for any help.
Kind regards,
Simon.

"Larry Linson" <bo*****@localhost.notschreef in bericht
news:wOZ1k.11225$%Z1.813@trnddc05...
You are aware, I presume, that there is no Access "Subreport" object.
There
is a Subreport Control, into which either a Report or a Form can be
imbedded. Code in a module or event of the parent Reportwould address
the
RecordSource of a Report or Form embedded into a Subreport Control is as
follows:

Reports!<yourreportname>!<subreportcontrolname>.Re port.RecordSource

Reports!<yourreportname>!<subreportcontrolname>.Fo rm.RecordSource

Me!<subreportcontrolname>.Report.RecordSource

OR

Me!<subreportcontrolname>.Form.RecordSource

But that would likely only add to your frustration, because at runtime
you
can only change the RecordSource of a Report in that Report's own Open
event. Thus you'd need to put the code in the Open event of the
Report/Form
embedded in the Subreport Control, as:

Me.RecordSource = whateveryouwanttosetitto

In a well-designed, well-implemented Access database it is so rare that
you'd need to change the RecordSource of a Report/Form embedded in a
Subreport Control, that I am obliged to ask you just what you are trying
to
accomplish by doing so. It's entirely possible that someone can offer a
useful suggestion for accomplishing the same purpose in a different way.

Generally, Subform and Subreport controls are used for displaying
information related to the Information currently displayed in their
parent
form or Report, and use the LinkMasterFields and LinkChildFields
properties
of the Subform or Subreport Controls to synchronize them.

Note that I don't rule out that you have encoutered an exception, and
really
do need to do what you are trying to do... but generally, in the past,
when
this has been asked, what's needed is not to change the RecordSource,
but to
change the layout/design of the data tables themselves.

Larry Linson
Microsoft Office Access MVP
"Simon" <Sv********@Versatel.nlwrote in message
news:48***********************@news.tele2.nl...
Dear reader,

The syntax for the VBA code to change the RecordSource of a Master
Report
is:

Me.RecordSource = "TableOrQueryName"

But now the syntax to change the RecordSource of a SubReport:

I think it has to be something like this:

Reports.MasterReportName.SubReportName.RecordSourc e =
"TableOrQueryName"

But this is not working.

Is there a working syntax for this?

Tanks for any help.

Kind regards,

Simon




Jun 27 '08 #3
No, I don't have a suggestion -- because it is "working as (I understand and
have understood since 1993 it to have been) designed."

The question I have is what in the world do you have in your data layout
that would cause you to _need_ to change the RecordSource in the related
child records joined to the key field in the master record you are
processing. Are the related records in the many side of the relationship in
different tables depending on the key value of the master table (thus
"hiding data in the object name")?

Larry Linson
Microsoft Office Access MVP
"Simon" <Sv********@Versatel.nlwrote in message
news:48***********************@news.tele2.nl...
Lary,

My SubReport is synchronized with a LinkMasterField and LinkChildField.
If I put in the Open event of the SubReport

Me.RecordSource = "QueryName"

an error pups up. It seems to be the SubReport on open event will be
activated after each record in the MasterReport. So an error pups up with
the massage "You can't change the RecordSource after the report is already
open".

Do you have a sugestion how to manage that.
Thanks for any help.
Kind regards,
Simon.

"Larry Linson" <bo*****@localhost.notschreef in bericht
news:wOZ1k.11225$%Z1.813@trnddc05...
You are aware, I presume, that there is no Access "Subreport" object.
There
is a Subreport Control, into which either a Report or a Form can be
imbedded. Code in a module or event of the parent Reportwould address
the
RecordSource of a Report or Form embedded into a Subreport Control is
as
follows:
>
Reports!<yourreportname>!<subreportcontrolname>.Re port.RecordSource
>
Reports!<yourreportname>!<subreportcontrolname>.Fo rm.RecordSource
>
Me!<subreportcontrolname>.Report.RecordSource
>
OR
>
Me!<subreportcontrolname>.Form.RecordSource
>
But that would likely only add to your frustration, because at runtime
you
can only change the RecordSource of a Report in that Report's own Open
event. Thus you'd need to put the code in the Open event of the
Report/Form
embedded in the Subreport Control, as:
>
Me.RecordSource = whateveryouwanttosetitto
>
In a well-designed, well-implemented Access database it is so rare that
you'd need to change the RecordSource of a Report/Form embedded in a
Subreport Control, that I am obliged to ask you just what you are
trying
to
accomplish by doing so. It's entirely possible that someone can offer
a
useful suggestion for accomplishing the same purpose in a different
way.
>
Generally, Subform and Subreport controls are used for displaying
information related to the Information currently displayed in their
parent
form or Report, and use the LinkMasterFields and LinkChildFields
properties
of the Subform or Subreport Controls to synchronize them.
>
Note that I don't rule out that you have encoutered an exception, and
really
do need to do what you are trying to do... but generally, in the past,
when
this has been asked, what's needed is not to change the RecordSource,
but to
change the layout/design of the data tables themselves.
>
Larry Linson
Microsoft Office Access MVP
>
>
"Simon" <Sv********@Versatel.nlwrote in message
news:48***********************@news.tele2.nl...
Dear reader,



The syntax for the VBA code to change the RecordSource of a Master
Report
is:



Me.RecordSource = "TableOrQueryName"



But now the syntax to change the RecordSource of a SubReport:

I think it has to be something like this:



Reports.MasterReportName.SubReportName.RecordSourc e =
"TableOrQueryName"



But this is not working.

Is there a working syntax for this?



Tanks for any help.

Kind regards,

Simon

>
>



Jun 27 '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...
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"
1
by: Simon | last post by:
Dear reader, My SubReport is synchronized with a LinkMasterField and LinkChildField. If I put in the Open event of the SubReport Me.RecordSource = "QueryName" an error pups up. It seems to...
3
by: Simon van Beek | last post by:
Dear reader, How to change the RecordSource for a subReport. For forms the syntaxes is:
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.