473,508 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting Subreport SourceObject Property

Hello,
I currently have an Access 2003 ADP Report/Subreport set up in which I have
12 subreports in a single main report that are located in a group header
called 'PermnumHeader' (Permnum would be the same as a numeric 'StudentID').
All subreports initially have their visible property set to 'No'.

I have a macro that evaulates the current value of a field in the detail
section of the main report called 'Grade' and a field in the same section
called 'Spanish', then sets the visible property of a single subreport to
'Yes' given a combination the Grade/Spanish values, and sets the visible
property in the other subreports to 'No'.

'Spanish' holds a value of zero or 1. If Spanish is 1, then a Spanish
report is generated, and if Spanish is zero, and English version is
generated.

The PermnumHeader_Format event of the PermnumHeader group header in the main
report fires the macro.

The report is designed to allow a teacher to preview a group of report cards
all at once, and have different report cards at different grade levels shown
in one of two languages.

I have attempted to change the way this report is generated, by coding a
procedure to run in the PermnumHeader_Format event. The code is as follows:

Private Sub PermnumHeader_Format(Cancel As Integer, FormatCount As Integer)

If Me.GRADE = "00" And Me.Spanish = False Then
Child50.SourceObject = "rptRCK"
ElseIf Me.GRADE = "00" And Me.Spanish = True Then
Child50.SourceObject = "rptRCKsp"

ElseIf Me.GRADE = "01" And Me.Spanish = False Then
Child50.SourceObject = "rptRC1"
ElseIf Me.GRADE = "01" And Me.Spanish = True Then
Child50.SourceObject = "rptRC1sp"

ElseIf Me.GRADE = "02" And Me.Spanish = False Then
Child50.SourceObject = "rptRC2"
ElseIf Me.GRADE = "02" And Me.Spanish = True Then
Child50.SourceObject = "rptRC2sp"

ElseIf Me.GRADE = "03" And Me.Spanish = False Then
Child50.SourceObject = "rptRC3"
ElseIf Me.GRADE = "03" And Me.Spanish = True Then
Child50.SourceObject = "rptRC3sp"

ElseIf Me.GRADE = "04" And Me.Spanish = False Then
Child50.SourceObject = "rptRC4-5"
ElseIf Me.GRADE = "04" And Me.Spanish = True Then
Child50.SourceObject = "rptRCK4-5sp"

ElseIf Me.GRADE = "05" And Me.Spanish = False Then
Child50.SourceObject = "rptRC4-5"
ElseIf Me.GRADE = "05" And Me.Spanish = True Then
Child50.SourceObject = "rptRC4-5sp"
Me.PermnumHeader.OnFormat

End If
End Sub

'Child50' is an 'empty' sub report that only has its link child and master
fields set to 'Permnum'.

The other thing that this code needs to do is set the record source for each
sub report. Normally, where I would just treat the report as a main report I
would handle that in the On Open event of the report as follows:

Private Sub Report_Open (Cancel As Integer, FormatCount As Integer)
Me.RecordSource = "EXEC dbo.RCSingleRCRpt_sp " & Forms!FrmRCMain!Permnum
End Sub

The SQL Server 2000 Stored Procedure, 'RCSingleRCRpt_sp' takes a 'Permnum'
(StudentID)parameter. The On Open event of the report would probably not
work here since as sub reports, they are not 'opening'. Would I use the On
Current event to set the record source?

Going back to my On Format problem, when I attempt to open the report in
print preview, the code on the On Format event runs for PermnumHeader, and I
get the following message:

"Runtime Error '2191':
You can't set the Source Object property in print preview or after printing
has started."

The report never displays in print preview.

How can I set up my reports/subreports so that On Format will work, and so
that the record sources for each sub report will be set correctly?

Thank you for your help!

CSDunn
Nov 12 '05 #1
3 4857
If you need to change the source object again for every page, you
will have to re-think your design: you can't do that. You can
probably set the source objects in the open event of the report,
or in the first format event of something. Also, the Format Event
has a FormatCount parameter: only set things when FormatCount=1.

If you need to repeatedly reset the recordsource for some object,
another way to do it is to bind to a table, and reload the table
for each page.
"CSDunn" <cd***@valverde.edu> wrote in message
news:80**************************@posting.google.c om...
Hello,
I currently have an Access 2003 ADP Report/Subreport set up in which I have 12 subreports in a single main report that are located in a group header
called 'PermnumHeader' (Permnum would be the same as a numeric 'StudentID'). All subreports initially have their visible property set to 'No'.

I have a macro that evaulates the current value of a field in the detail
section of the main report called 'Grade' and a field in the same section
called 'Spanish', then sets the visible property of a single subreport to
'Yes' given a combination the Grade/Spanish values, and sets the visible
property in the other subreports to 'No'.

'Spanish' holds a value of zero or 1. If Spanish is 1, then a Spanish
report is generated, and if Spanish is zero, and English version is
generated.

The PermnumHeader_Format event of the PermnumHeader group header in the main report fires the macro.

The report is designed to allow a teacher to preview a group of report cards all at once, and have different report cards at different grade levels shown in one of two languages.

I have attempted to change the way this report is generated, by coding a
procedure to run in the PermnumHeader_Format event. The code is as follows:
Private Sub PermnumHeader_Format(Cancel As Integer, FormatCount As Integer)
If Me.GRADE = "00" And Me.Spanish = False Then
Child50.SourceObject = "rptRCK"
ElseIf Me.GRADE = "00" And Me.Spanish = True Then
Child50.SourceObject = "rptRCKsp"

ElseIf Me.GRADE = "01" And Me.Spanish = False Then
Child50.SourceObject = "rptRC1"
ElseIf Me.GRADE = "01" And Me.Spanish = True Then
Child50.SourceObject = "rptRC1sp"

ElseIf Me.GRADE = "02" And Me.Spanish = False Then
Child50.SourceObject = "rptRC2"
ElseIf Me.GRADE = "02" And Me.Spanish = True Then
Child50.SourceObject = "rptRC2sp"

ElseIf Me.GRADE = "03" And Me.Spanish = False Then
Child50.SourceObject = "rptRC3"
ElseIf Me.GRADE = "03" And Me.Spanish = True Then
Child50.SourceObject = "rptRC3sp"

ElseIf Me.GRADE = "04" And Me.Spanish = False Then
Child50.SourceObject = "rptRC4-5"
ElseIf Me.GRADE = "04" And Me.Spanish = True Then
Child50.SourceObject = "rptRCK4-5sp"

ElseIf Me.GRADE = "05" And Me.Spanish = False Then
Child50.SourceObject = "rptRC4-5"
ElseIf Me.GRADE = "05" And Me.Spanish = True Then
Child50.SourceObject = "rptRC4-5sp"
Me.PermnumHeader.OnFormat

End If
End Sub

'Child50' is an 'empty' sub report that only has its link child and master
fields set to 'Permnum'.

The other thing that this code needs to do is set the record source for each sub report. Normally, where I would just treat the report as a main report I would handle that in the On Open event of the report as follows:

Private Sub Report_Open (Cancel As Integer, FormatCount As Integer)
Me.RecordSource = "EXEC dbo.RCSingleRCRpt_sp " & Forms!FrmRCMain!Permnum
End Sub

The SQL Server 2000 Stored Procedure, 'RCSingleRCRpt_sp' takes a 'Permnum'
(StudentID)parameter. The On Open event of the report would probably not
work here since as sub reports, they are not 'opening'. Would I use the On
Current event to set the record source?

Going back to my On Format problem, when I attempt to open the report in
print preview, the code on the On Format event runs for PermnumHeader, and I get the following message:

"Runtime Error '2191':
You can't set the Source Object property in print preview or after printing has started."

The report never displays in print preview.

How can I set up my reports/subreports so that On Format will work, and so
that the record sources for each sub report will be set correctly?

Thank you for your help!

CSDunn

Nov 12 '05 #2
David,
Thanks for your help. The record source can be made the same for each
report, I would just need to reconfigure how the reports are used when
they are viewed individually.

Maybe I'll have to go back to having the reports 'stacked' again as
sub reports in a main report.

CSDunn

"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message news:<40***********************@news.syd.swiftdsl. com.au>...
If you need to change the source object again for every page, you
will have to re-think your design: you can't do that. You can
probably set the source objects in the open event of the report,
or in the first format event of something. Also, the Format Event
has a FormatCount parameter: only set things when FormatCount=1.

If you need to repeatedly reset the recordsource for some object,
another way to do it is to bind to a table, and reload the table
for each page.
"CSDunn" <cd***@valverde.edu> wrote in message
news:80**************************@posting.google.c om...
Hello,
I currently have an Access 2003 ADP Report/Subreport set up in which I

have
12 subreports in a single main report that are located in a group header
called 'PermnumHeader' (Permnum would be the same as a numeric

'StudentID').
All subreports initially have their visible property set to 'No'.

I have a macro that evaulates the current value of a field in the detail
section of the main report called 'Grade' and a field in the same section
called 'Spanish', then sets the visible property of a single subreport to
'Yes' given a combination the Grade/Spanish values, and sets the visible
property in the other subreports to 'No'.

'Spanish' holds a value of zero or 1. If Spanish is 1, then a Spanish
report is generated, and if Spanish is zero, and English version is
generated.

The PermnumHeader_Format event of the PermnumHeader group header in the

main
report fires the macro.

The report is designed to allow a teacher to preview a group of report

cards
all at once, and have different report cards at different grade levels

shown
in one of two languages.

I have attempted to change the way this report is generated, by coding a
procedure to run in the PermnumHeader_Format event. The code is as

follows:

Private Sub PermnumHeader_Format(Cancel As Integer, FormatCount As

Integer)

If Me.GRADE = "00" And Me.Spanish = False Then
Child50.SourceObject = "rptRCK"
ElseIf Me.GRADE = "00" And Me.Spanish = True Then
Child50.SourceObject = "rptRCKsp"

ElseIf Me.GRADE = "01" And Me.Spanish = False Then
Child50.SourceObject = "rptRC1"
ElseIf Me.GRADE = "01" And Me.Spanish = True Then
Child50.SourceObject = "rptRC1sp"

ElseIf Me.GRADE = "02" And Me.Spanish = False Then
Child50.SourceObject = "rptRC2"
ElseIf Me.GRADE = "02" And Me.Spanish = True Then
Child50.SourceObject = "rptRC2sp"

ElseIf Me.GRADE = "03" And Me.Spanish = False Then
Child50.SourceObject = "rptRC3"
ElseIf Me.GRADE = "03" And Me.Spanish = True Then
Child50.SourceObject = "rptRC3sp"

ElseIf Me.GRADE = "04" And Me.Spanish = False Then
Child50.SourceObject = "rptRC4-5"
ElseIf Me.GRADE = "04" And Me.Spanish = True Then
Child50.SourceObject = "rptRCK4-5sp"

ElseIf Me.GRADE = "05" And Me.Spanish = False Then
Child50.SourceObject = "rptRC4-5"
ElseIf Me.GRADE = "05" And Me.Spanish = True Then
Child50.SourceObject = "rptRC4-5sp"
Me.PermnumHeader.OnFormat

End If
End Sub

'Child50' is an 'empty' sub report that only has its link child and master
fields set to 'Permnum'.

The other thing that this code needs to do is set the record source for

each
sub report. Normally, where I would just treat the report as a main report

I
would handle that in the On Open event of the report as follows:

Private Sub Report_Open (Cancel As Integer, FormatCount As Integer)
Me.RecordSource = "EXEC dbo.RCSingleRCRpt_sp " & Forms!FrmRCMain!Permnum
End Sub

The SQL Server 2000 Stored Procedure, 'RCSingleRCRpt_sp' takes a 'Permnum'
(StudentID)parameter. The On Open event of the report would probably not
work here since as sub reports, they are not 'opening'. Would I use the On
Current event to set the record source?

Going back to my On Format problem, when I attempt to open the report in
print preview, the code on the On Format event runs for PermnumHeader, and

I
get the following message:

"Runtime Error '2191':
You can't set the Source Object property in print preview or after

printing
has started."

The report never displays in print preview.

How can I set up my reports/subreports so that On Format will work, and so
that the record sources for each sub report will be set correctly?

Thank you for your help!

CSDunn

Nov 12 '05 #3
Even just setting a sub report to not visible may force it to not
calculate at all - there may not be any real overhead to using
stacked sub-reports. You may also try to use the "link child fields/
link master fields" properties - it may speed up your report because
the sub-reports won't calculate if they are empty. Another option
might be to dynamically reconfigure a single sub-report: you can
shift controls and make them visible/invisible in the format event
for a section.

"CSDunn" <cd***@valverde.edu> wrote in message
news:80**************************@posting.google.c om...
David,
Thanks for your help. The record source can be made the same for each
report, I would just need to reconfigure how the reports are used when
they are viewed individually.

Maybe I'll have to go back to having the reports 'stacked' again as
sub reports in a main report.

CSDunn

"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message

news:<40***********************@news.syd.swiftdsl. com.au>...
If you need to change the source object again for every page, you
will have to re-think your design: you can't do that. You can
probably set the source objects in the open event of the report,
or in the first format event of something. Also, the Format Event
has a FormatCount parameter: only set things when FormatCount=1.

If you need to repeatedly reset the recordsource for some object,
another way to do it is to bind to a table, and reload the table
for each page.
"CSDunn" <cd***@valverde.edu> wrote in message
news:80**************************@posting.google.c om...
Hello,
I currently have an Access 2003 ADP Report/Subreport set up in which I

have
12 subreports in a single main report that are located in a group header called 'PermnumHeader' (Permnum would be the same as a numeric

'StudentID').
All subreports initially have their visible property set to 'No'.

I have a macro that evaulates the current value of a field in the detail section of the main report called 'Grade' and a field in the same section called 'Spanish', then sets the visible property of a single subreport to 'Yes' given a combination the Grade/Spanish values, and sets the visible property in the other subreports to 'No'.

'Spanish' holds a value of zero or 1. If Spanish is 1, then a Spanish
report is generated, and if Spanish is zero, and English version is
generated.

The PermnumHeader_Format event of the PermnumHeader group header in the
main
report fires the macro.

The report is designed to allow a teacher to preview a group of report

cards
all at once, and have different report cards at different grade levels

shown
in one of two languages.

I have attempted to change the way this report is generated, by coding
a procedure to run in the PermnumHeader_Format event. The code is as

follows:

Private Sub PermnumHeader_Format(Cancel As Integer, FormatCount As

Integer)

If Me.GRADE = "00" And Me.Spanish = False Then
Child50.SourceObject = "rptRCK"
ElseIf Me.GRADE = "00" And Me.Spanish = True Then
Child50.SourceObject = "rptRCKsp"

ElseIf Me.GRADE = "01" And Me.Spanish = False Then
Child50.SourceObject = "rptRC1"
ElseIf Me.GRADE = "01" And Me.Spanish = True Then
Child50.SourceObject = "rptRC1sp"

ElseIf Me.GRADE = "02" And Me.Spanish = False Then
Child50.SourceObject = "rptRC2"
ElseIf Me.GRADE = "02" And Me.Spanish = True Then
Child50.SourceObject = "rptRC2sp"

ElseIf Me.GRADE = "03" And Me.Spanish = False Then
Child50.SourceObject = "rptRC3"
ElseIf Me.GRADE = "03" And Me.Spanish = True Then
Child50.SourceObject = "rptRC3sp"

ElseIf Me.GRADE = "04" And Me.Spanish = False Then
Child50.SourceObject = "rptRC4-5"
ElseIf Me.GRADE = "04" And Me.Spanish = True Then
Child50.SourceObject = "rptRCK4-5sp"

ElseIf Me.GRADE = "05" And Me.Spanish = False Then
Child50.SourceObject = "rptRC4-5"
ElseIf Me.GRADE = "05" And Me.Spanish = True Then
Child50.SourceObject = "rptRC4-5sp"
Me.PermnumHeader.OnFormat

End If
End Sub

'Child50' is an 'empty' sub report that only has its link child and master fields set to 'Permnum'.

The other thing that this code needs to do is set the record source for each
sub report. Normally, where I would just treat the report as a main
report I
would handle that in the On Open event of the report as follows:

Private Sub Report_Open (Cancel As Integer, FormatCount As Integer)
Me.RecordSource = "EXEC dbo.RCSingleRCRpt_sp " &
Forms!FrmRCMain!Permnum End Sub

The SQL Server 2000 Stored Procedure, 'RCSingleRCRpt_sp' takes a 'Permnum' (StudentID)parameter. The On Open event of the report would probably not work here since as sub reports, they are not 'opening'. Would I use the On Current event to set the record source?

Going back to my On Format problem, when I attempt to open the report in print preview, the code on the On Format event runs for PermnumHeader, and I
get the following message:

"Runtime Error '2191':
You can't set the Source Object property in print preview or after

printing
has started."

The report never displays in print preview.

How can I set up my reports/subreports so that On Format will work,

and so that the record sources for each sub report will be set correctly?

Thank you for your help!

CSDunn

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
13209
by: dixie | last post by:
I have a report with a subreport. The source object for this subreport varies according to the value of a field in a table. I am trying to programmatically set the object source for the subreport...
7
2183
by: Jacob Barnett | last post by:
Access 2000 main report does not display subreport data in preview and may or may not print... sometimes. Usually, the entire report is fine. The behavior does not seem to depend on particular...
3
573
by: CSDunn | last post by:
Hello, I currently have an Access 2003 ADP Report/Subreport set up in which I have 12 subreports in a single main report that are located in a group header called 'PermnumHeader' (Permnum would be...
9
2812
by: Downstreamer | last post by:
Design is as follows: A form for the user to input criteria to be used as the where part of the report's recordsource. This includes a multiselect list box as part of the criteria selection. ...
7
3556
by: Ellen Manning | last post by:
I've got an A2K report showing students and their costs. Student info is in the main report and costs are in a subreport for each student. The user inputs the program desired then only those...
1
7646
by: Kirsty Ryder | last post by:
Hi, I have a Report with a subreport, and I want to assign a value to the control source of a control on the subreport depending on the value given by the user in a separate form. Based on...
11
7432
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
1903
Breezwell
by: Breezwell | last post by:
First off, let me say that this forum has provided me with numerous guidance to Access programming challenges I have faced while learning, and I am grateful to all those who share thier knowledge...
3
10653
by: Simon van Beek | last post by:
Dear reader, How to change the RecordSource for a subReport. For forms the syntaxes is:
0
7328
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,...
1
7049
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
7499
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
5631
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,...
1
5055
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...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
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...
0
1561
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 ...
1
767
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.