473,763 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = "TableOrQueryNa me"

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

I think it has to be something like this:

Reports.MasterR eportName.SubRe portName.Record Source =
"TableOrQueryNa me"

But this is not working.

Is there a working syntax for this?

Tanks for any help.

Kind regards,

Simon

Jun 27 '08 #1
3 9405
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!<yourre portname>!<subr eportcontrolnam e>.Report.Recor dSource

Reports!<yourre portname>!<subr eportcontrolnam e>.Form.RecordS ource

Me!<subreportco ntrolname>.Repo rt.RecordSource

OR

Me!<subreportco ntrolname>.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 = whateveryouwant tosetitto

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 LinkMasterField s 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********@Ver satel.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 = "TableOrQueryNa me"

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

I think it has to be something like this:

Reports.MasterR eportName.SubRe portName.Record Source =
"TableOrQueryNa me"

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*****@localh ost.notschreef in bericht
news:wOZ1k.1122 5$%Z1.813@trndd c05...
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!<yourre portname>!<subr eportcontrolnam e>.Report.Recor dSource

Reports!<yourre portname>!<subr eportcontrolnam e>.Form.RecordS ource

Me!<subreportco ntrolname>.Repo rt.RecordSource

OR

Me!<subreportco ntrolname>.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 = whateveryouwant tosetitto

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 LinkMasterField s 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********@Ver satel.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 = "TableOrQueryNa me"

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

I think it has to be something like this:

Reports.MasterR eportName.SubRe portName.Record Source =
"TableOrQueryNa me"

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********@Ver satel.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*****@localh ost.notschreef in bericht
news:wOZ1k.1122 5$%Z1.813@trndd c05...
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!<yourre portname>!<subr eportcontrolnam e>.Report.Recor dSource
>
Reports!<yourre portname>!<subr eportcontrolnam e>.Form.RecordS ource
>
Me!<subreportco ntrolname>.Repo rt.RecordSource
>
OR
>
Me!<subreportco ntrolname>.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 = whateveryouwant tosetitto
>
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 LinkMasterField s 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********@Ver satel.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 = "TableOrQueryNa me"



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

I think it has to be something like this:



Reports.MasterR eportName.SubRe portName.Record Source =
"TableOrQueryNa me"



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
3128
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 in several different 'main' reports. I have tried to use the following code; Me.RptTeacherHistory2.Properties("RecordSource") = "EXEC RCTeacherHistory_sp " & Me.Permnum 'RCTeacherHistory' is a proc that takes 'permnum' as a single
6
9472
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 ?? Thanks in advance
8
1843
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
3456
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 = SQL Statement Also Tried: Me!.RecordSource = SQL Statement My syntax is not right. Can anyone help? Thanks, Hank Reed
8
23818
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
7458
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
566
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 be that the open event of the SubReport will be activated after each record in the MasterReport. So an error pups up with
3
10691
by: Simon van Beek | last post by:
Dear reader, How to change the RecordSource for a subReport. For forms the syntaxes is:
7
10113
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 = ".\SQLEXPRESS" Dim oldDatabaseName As String = oldDatabaseName Dim newServerName As String = newServerName Dim newDatabaseName As String = newDatabaseName Dim UserID As String = "" Dim Password As String = ""
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10145
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8822
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.