SubReports at runtime

pskalpana
pskalpana used Ask the Experts™
on
i am using crystal report 8.5 and vb6 with oracle 9i as backend

i have to create subreports at run time. how do i go about doing that.

i need to create them because based on certain condition i might get 1 or more records. if more than one records are obtained, i have to find the difference between first 2 records with the MINUS clause and diplay it in the report. i have to do the same for the subsequent 2 records each till the last record. so my RecordSet will be different each time and so i need to display it in a different subreport, if i am correct.

ex:
record 1
record 2
record 3
record 4

1a)
select * from record1
MINUS
select * from record2

1b)
select * from record2
MINUS
select * from record1

2a)
select * from record2
MINUS
select * from record3

2b)
select * from record3
MINUS
select * from record2

and so on ....

report output should be:
------------------------
Added:
1a) output records

Deleted:
1b) output records

Added:
2a) output records

Deleted:
2b) output records

and so on ....


can anybody out there suggest me a solution for this.
its URGENT!!!!

Thanks in Advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
What exactly are you trying to do?  Can you give a concrete example with data?

mlmcc
Commented:
If you want to create a subreport on-the-fly, look at the attached Crystal example.  It creates the main report at runtime also, though you can just look at the subreport section.

http://support.crystaldecisions.com/library/kbase/articles/c2007211.asp

Another way might be to have a few subreports already created, then import the desired one based on certain conditions.  Look here for an example:

http://support.crystaldecisions.com/library/kbase/articles/c2007212.asp

There are a lot of other good examples for subreports on the Crystal Website.  Go to http://support.crystaldecisions.com/library/Kbase.asp and search on subreport.

Hope this helps.
I believe it is better to use pre-created subreports and if you want to feed them different data - there are ways to do this.

Are you using VB?  How are you executing the report?
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Author

Commented:
hi,
sorry for the late reply,

this is to dbirdman

as i will have varying number of recordsets (1 to n) i thought of creating the subreports on the fly. i tried doing so.

1)
i could create blank subreport in the same section(say the first 'Report Footer' RF Section).
when i tried to assign a ado field to a sub report, i got 'subscript out of range' error. ie.,

Report.database.setdatasource rs 'where rs is the resultset

2)
i want to create the subreport in different "ReportFooter" sections of the report so as to avoid overlapping of the data in the subreports.so how to i create report sections at runtime

3)
for the runtime section creation, i could not find any examples. the existing examples gave creating subreport to an exisiting section


Do the recordsets have the same fields?

If so, you could create a Stored Procedure that places the recordsets into a temporary table with an extra unique field per set called SetNumber - or something.

Now you build a report based on this SP and group on SetNumber.

Author

Commented:
no, the recordsets will not have same fields
Do the record sets come in patterns of fields?

Like one type of set displays fields A, B, C and another uses D, E, F?

Commented:
Try this example for adding a Section:

Creating a Report and adding and deleting a Section:
http://support.crystaldecisions.com/library/kbase/articles/c2007205.asp

The valid section types are as follows:
 "RH", "PH", "GHn", "D", "GFn", "PF", or "RF"

GHn and GFn would be Group Header 1, 2, etc...

Multiple sections of the same type would be Da, Db, etc...

Hope this helps.
This question has been classified abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.


Unless it is clear to me that the question has been answered I will recommend delete. It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.


If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp

Pat K
EE Cleanup Volunteer

Perhaps give this to dbirdman since the person didn't return after the last suggestion.

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: dbirdman {http:#7483594}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

mnye
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial