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!

Crystal Reports master/detail report?

Status
Not open for further replies.

Blitz

Technical User
Jul 7, 2000
171
US
I am trying to make a report that shows the information from the parent record then shows all the child record and continues for all records

similar to this

Entry 1 information
Detail information
Detail information
Detail information

Entry 2 information
Detail information
Detail information

etc....

I cant seem to find any information on how to do this. I can easily create a report that shows just the parent information but i have no idea how to get it to show the child records.

I am trying to make this from a dataset with the 2 tables and the relationship between them. I have used the report designer and added both tables but no matter what i do i get a report that is just based on a joined table made from the 2.

Any help or a link to a example would be most helpful, thanks.
 
A Subreport will work, but that will require a great deal more overhead. You can group your data in Crystal reports and add all your "master" information in the "Group" section and your detail information in the "Detail" section.
 
If you want to group on more than one field, i.e., displaying the ID, Name, Address, etc. of the "Master", it gets a little bit harder, stravis.
 
I had just figured that out. My problem was that I did not see any way to group, but i have figured out what i needed to. Thanks.
 
Actually, you just create a grouping by whatever field it is that you wish to group by, and then you add all the fields to that grouping that you wish to have displayed. If you need to group by more than one field, then create a grouping for each field in the order you wish to group by, and then you can suppress those group sections you don't wish to see. Crystal Reports will create a section with the group name when you create a new group, but there is no reason that you need to keep the group name field, or limit the fields displayed in the group section to the one field that Crystal Reports adds by itself.

Usually, the only time that you have a need for a subreport is when he detail for a report is not expressable in a list format. Most reports can be created with a combanation of group sections, one or more detail sections, and Crystal expressions, supressions, and formatting. This is the preferred method of report development due to the increase on speed. When you insert a subreport in a detail section of a report a report is executed every time the subreport is called, which significantly slows down the report generation process, and strains system, network, and database resources.
 
I don't see how adding and supressing sections is more effecient. To bring it over on one report...you either have to A.) Create a join query that brings the master attributes over with all the details, and just suppress the master attributes in the details (bring over a significantly larger dataset), or B.) Bring over two tables and join them in Crystal.

With B.), I am not sure on whether that is more effecient than A.

I also don't understand your comment about subreports straining resources. I have many reports with subreports in ASP.Net on a LAN....and I really can't tell the difference between it and reports with only one report.
 
I'm not quite sure what you are trying to say in your first two paragraphs, but as far as subreports straining resources in your environment I can say that you are right. You probably can't tell the difference with the reports you are running. Where you begin to noticably see the difference is when you are running large reports that have complex report structures with multiple subreports. The slower the system you are executing these reports from, the more significant the difference.

Unfortunately with modern day systems it is difficult to see the strain on resources that our coding creates due to the fact that greater system resources allows us to be fairly sloppy. I don't think it is necessary to get crazy and go out of our way to make every piece of code super efficient, but in my experience through the years with Crystal Reports I have found that this is one program you should be effecient as possible with. However, now that systems have a little more processing power than they use to, you probably can afford to put more subreports in to a report without seeing a difference. However, the main thrust of my original message is that a subreport in this particual instance is completely unnecessary. Use the group section to put master or header information and then use the detail section to put your detail. It's simple, not insane, and so not worth arguing over.
 
No, stravis, I agree with your methods, and know they will work, etc. From my experience, I USUALLY have used subreports when showing a lot of data in the Master group. There has been plenty of times where I grouped on the ID, and drug the Name field up to the group header.

My only concern was....if you had brought over you master and detail data in one flat table....that's more data that you need, possibly negating performance increases.

I'm done here.
 
I understand what you are trying to say now. I suppose that you are right in the possible negation of performance. I really don't know without doing some testing if this would be the case or not though. Sorry for the misunderstanding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top