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 not linking to all records in main report

Status
Not open for further replies.

Delta55

Programmer
Aug 31, 2005
2
US
Hello,

I have a newbie question regarding subreports in Crystal Reports 8.5. I'm used to Access, but my boss insists that I use Crystal Reports for my current project.

Anyways, everything in my Crystal Reports report is fine, except that my subreport is not linking to all the records in the main report.

In my main report, the records grouped by "Project" and lists the Tasks associated with that Project and summary info for these Tasks. I have arranged it so that each Project has its own page (new page after the Project footer). This part is fine.

The Project group footer contains a subreport that is based on a separate table. This subreport is supposed to show the people involved in each task and their associated data.

My goal is to have the main report data (Task data) show up together in one section the upper portion of the report and the subreport show up in one section in the lower part of the report. So I want it to look like this:

------------------------------------------- (start of page -- main report)
Project A


Task Estimate Actual
---- -------- ------
Task A 100 250
Task B 200 100
Task C 300 300

Proj A totals xyz xyz

------------------------------------------- (subreport)

Task A

People Hours Pay
------ ----- ---
Person 1 40 100
Person 2 35 250
A subtotals xy xyz


Task B

People Hours Pay
------ ----- ---
Person 4 50 150
Person 6 25 125
B subtotals xy xyz


Task C

People Hours Pay
------ ----- ---
Person 7 45 100
Person 9 40 175
C subtotals xy xyz


Proj A totals xy xyz


------------------------------------------- (end of subreport -- end of page)


However, as it stands, the subreport doesn't show all the Tasks. It shows only the last Task (Task C in this example). I have the subreport linked to the main report by Task, although I also have a Project field available in the subreport data to link on as well.

The way I see it is that when I link by Task number, only the last Task "read" in the main report is used to grab the subreport data, so I only get People info for the last Task.

If I link the subreport to the main report by Project instead of by Task, the subreport shows all the Tasks, but also shows items that shouldn't show up. Don't ask me why this is--I have no control over the data. Apparently, the subreport data contains items that don't show up in the main report data, so it shouldn't show up in the subreport either. If not for this quirk in the subreport data, I think I'd able to link on the Project field instead of the Task field and everything would be fine.

I've also tried linking the subreport by Project and then using a secondary link to Task, but that still results in only the last Task showing up. I'm trying to figure out if it is possible to use an array to store the Task numbers in the main report and then use that as a filter for the subreport.

If I add a Task group to the main report and place the subreport in the Task group footer, the subreport shows all the revelant Tasks, but separately following each Task, not in one "summary" section at the bottom of the page. So instead of a Task summary section and People summary section, I get three separate Task-People sections, which is not what I want.

I'm beginning to think a subreport can only link to fields (parameters?) that consist of one value and not multiple values (like I'm trying to do--having the subreport link to Tasks A, B, and C). I hope I'm wrong about this though...

Is there a simple way to get the subreport data I want in the form I want?

Thanks for any advice.
 
The subreport will execute based on where it is placed on the main report. Where is your subreport?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
If you want to see all the tasks for a project then you must link the subreport to the main report on Project.

Your problemi s then how to filter the unwanted data from the subreport, In teh main report you must have a table that contains the tasks in a project, try adding this same table to the subreport.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Thanks to both of you for responding.

dgillz, the subreport is in the Project group footer because I want it to execute once per Project.

GJParker, adding the main report's table (which does contain the Tasks that are in each Project) to the subreport is something I haven't tried yet. I don't know why I hadn't considered it. I guess it was because I was so fixated on thinking there was a problem in the linking between the main report and the subreport that I didn't bother looking elsewhere.

However, I can't actually try anything until I go to work tomorrow, but I did do a quick 'n dirty mockup using Access 2000. I was able to repeat the "last-Task-only-in-the-subreport" phenomenon when linking by Task. Upon changing the link to Project and "equal" joining the main table to the subreport's table in the subreport query, things ran perfectly. No unwanted data. I hope the same thing happens tomorrow when I try it out in Crystal...

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top