How to programatically add an existing report to a report (as sub)

E

Elijah

I have a report that I want to add as a sub report

In my main report's "On Open" event I want to do something like this:

Private Sub Report_Open(Cancel As Integer)

Dim I as Integer
For i = 0 to X

'Insert my subreport (which already exists)
'Add a page break.

Next

End Sub

I've looked at CreateReportControl and CreateReport respectively- but
I am not wanting to programatically create the entire report, I just
want to add X copies of the same report (and pass them a single
Integer value as the DB parameter EG "i")

Is this possible?
 
M

Marshall Barton

Elijah said:
I have a report that I want to add as a sub report

In my main report's "On Open" event I want to do something like this:

Private Sub Report_Open(Cancel As Integer)

Dim I as Integer
For i = 0 to X

'Insert my subreport (which already exists)
'Add a page break.

Next

End Sub

I've looked at CreateReportControl and CreateReport respectively- but
I am not wanting to programatically create the entire report, I just
want to add X copies of the same report (and pass them a single
Integer value as the DB parameter EG "i")


You are absolutely correct about not using
CreateReport/CreateControl. THose thing are only there so
you can create your own wizards to help you design your
reports. They should not be used in a running program.

Try creating a little table with one field (named Num)
populated with records containing 1 through X. Then create
a new report bound to that table. Use Sorting and Grouping
to sort on the Num field.

Next. add a text box (named txtNum) to the detail section
and bind it to the Num field. Then drag/drop your existing
report into the detail section of the new report. Set the
LinkMasterFields property of the subreport control to txtNum
and the LinkChildFields property to the field that contains
the number.

Set the main report detail section's ForceNewPage property
to Before Section get each subreport on a new page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top