473,324 Members | 2,196 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,324 software developers and data experts.

How to programmatically add a subreport into main report

Hi,

I can add a subreport into the main report at the develop time (visual way),
and everything works fine. However, I'd like to know how to do the same task
at the run time, ie, when the main report is loading, the second report is
adding into it.

Both reports 'main.rpt', and 'subreport.rpt' are predefined, I only want to
know how to link them together.

I will approciate if somebody can help me.
Nov 21 '05 #1
2 5027
Hi Li,

We need to write the following code to add the controls dynamically :
START CODE

Dim myLabel As New DataDynamics.ActiveReports.Label()

myLabel.Text = "Test"

myLabel.Name = "Label1"

myLabel.Width = rpt.PrintWidth

myLabel.Top = 0

myLabel.Left = 0

myLabel.Height = 1

myLabel.Style = "text-align: center; font-weight: bold; font-size: 72pt;"

rpt.Sections("Detail").Controls.Add(myLabel)

END CODE

We need to add teh following code in order to add a section dynamically :

START CODE

With rpt.Sections
.Add(SectionType.PageHeader, "PageHeader")
.Add(SectionType.Detail, "Detail")
.Add(SectionType.PageFooter, "PageFooter")
End With

END CODE

Hope thsi helps.

Regards,

Mona [Grapecity]

"Li Pang" <Li****@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
Hi,

I can add a subreport into the main report at the develop time (visual way), and everything works fine. However, I'd like to know how to do the same task at the run time, ie, when the main report is loading, the second report is
adding into it.

Both reports 'main.rpt', and 'subreport.rpt' are predefined, I only want to know how to link them together.

I will approciate if somebody can help me.

Nov 21 '05 #2
Hi Mona,

Thanks for your response. However, I can't see any codes concerning to link
two existing reports.

"Mona" wrote:
Hi Li,

We need to write the following code to add the controls dynamically :
START CODE

Dim myLabel As New DataDynamics.ActiveReports.Label()

myLabel.Text = "Test"

myLabel.Name = "Label1"

myLabel.Width = rpt.PrintWidth

myLabel.Top = 0

myLabel.Left = 0

myLabel.Height = 1

myLabel.Style = "text-align: center; font-weight: bold; font-size: 72pt;"

rpt.Sections("Detail").Controls.Add(myLabel)

END CODE

We need to add teh following code in order to add a section dynamically :

START CODE

With rpt.Sections
.Add(SectionType.PageHeader, "PageHeader")
.Add(SectionType.Detail, "Detail")
.Add(SectionType.PageFooter, "PageFooter")
End With

END CODE

Hope thsi helps.

Regards,

Mona [Grapecity]

"Li Pang" <Li****@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
Hi,

I can add a subreport into the main report at the develop time (visual

way),
and everything works fine. However, I'd like to know how to do the same

task
at the run time, ie, when the main report is loading, the second report is
adding into it.

Both reports 'main.rpt', and 'subreport.rpt' are predefined, I only want

to
know how to link them together.

I will approciate if somebody can help me.


Nov 21 '05 #3

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

Similar topics

4
by: deko | last post by:
I can't move a multi-page report to the last record unless I keep the popup form (that defined it's subreports) open. DoCmd.OpenReport "rptStandard", acViewNormal DoCmd.Close acForm,...
1
by: Manal/report designer | last post by:
Thank you in advance for any suggestions... I'm using crystal reports version 8 & SQL server. I've created a report that is composed of 2 parts: 1st part contains the main report which uses...
2
by: Eddie Smit | last post by:
Hi all, I created a main report with a subreport. I want to display this subreport 8 times but with different data. (I do that with subreport.RecordSource = "sqlstring") HOW do I set this...
7
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...
6
by: Steve Jorgensen | last post by:
I tried to fix a problem for a client today in which report sections and even individual text controls in some of their reports are being split across page boundaries. Of course, I was thinking...
1
by: shaqattack1992-newsgroups | last post by:
I know this is kind of a weird question, but is there anyway to give a subreport control of a main report? I posted my situation earlier about having drawings print out after a group. I have a...
3
by: lorirobn | last post by:
Hello, I have a report which uses a subreport. When I run the report, I get "Enter Parameter Value" error message for "tblGuestRoom". I click ok and the report seems to work fine. I...
3
by: Coll | last post by:
I have a report that I run every quarter. When I opened it this quarter, one of the subreports is not displaying. No error message - just nothing displays where the subreport data should be. If you...
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"
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: 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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.