473,287 Members | 1,865 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 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 9323
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.