Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport repeats for every record of main report

Status
Not open for further replies.

kamv

MIS
Jun 14, 2002
22
US
Hi,
I have a subreport linked to a main report. The problem I am having is that all the records in the subreport repeat for every 1 record in the main report. How do I fix this?
Also, how do I sort the records by name so that all the records in both the main and subreport are sorted together?
Thanks!
 
Where in the Main report did you place the Subreport, and what sort of link did you use?

If you just place a subreport into the details section without a link, it will do precisely what you're experiencing.

Place the sub where you want the data (might be the detail), and set a link between the two reports.

Right click the subreport and select change subreport links.

-k kai@informeddatadecisions.com
 
I have tried placing the subreport in both the detail section and a group section and have gotten the same result - all the records in the subreport repeat for every 1 record in the main report. The link is set up based on a formula (See my earlier posting: Linking Subreport with Date parameters 6/27/02) using a date field. I also still can't figure out how to sort all the records (for both reports).
 
If you want the subreport to print once per group, you need to have the link based on a group formula, not a detail formula. Please post the formula you are basing the link on and maybe I can help. Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
The formula is:
Date({PURCHASE.DATE})
It is created in the subreport. I have 2 parameters in the main report - Start Date and End Date. I want to link the subreport to the main using those two parameters so what ever data the main reports gets for that date range the subreport gets its data from the same date range. The problem I had with that was that the database field is actually a date/time field. When setting up the parameters in the main report I set them up as date types because I want the user to only have to enter in a date and not time. When trying to link that to the subreport it would not work because it was looking for a date/time field not a date field (See my earlier posting: Linking Subreport with Date parameters 6/27/02). Some one suggested using that formula in the subreport to link to the main report. I want the main report and subreport to look like 1 report - all records from both reports sorted by name.
I appreciate your help.
Kamv
 
You did not address my point at all about your subreport. Do you want the subreport after a group in your main report, or after a single detail record?

Your formula is a detail formula - there is one result of your formula for every single record in your database. If you link on the date formula in the details section, you will get everything with that date. I somehow doubt this is what you want. Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
You are correct I don't want a result for every record in the database, I want the subreport after a group in the main report. Thanks again.
Kamv
 
What is your group? Is it by date? Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
If the group is by name, why are you trying to link on a formula field that retuens a date?

You need to link from the name field of the main report to the name field of the subreport. Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
I also read your earlier posts. I think the problem is confusing links with subreport criteria.

What I think you want:

A subreport for each group (name) that is limited by the same date range given as paramters to the main report.

If this is correct, you need to link by the "name". You need to create shared variables that contain the value of the parameter and then use those to limit by date.

In the main report (preferably the report header)

Formula: SetStartDate

Shared DateTimeVar StartDate := {?StartDate}

In the subreport:

Formula: GetStartDate

Shared DateTimeVarStartDate;
StartDate

Then use that formula in your select statement for the subreport:

table.datetime >= {@GetStartDate}


That should get you where you are going.

Lisa


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top