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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reporting from a recursive relationship in a database

Status
Not open for further replies.

flepkows

Programmer
Jun 7, 2004
17
US
I am reporting off of an access database using CR bundled with VS.net. There are two tables in my database i.e. Parts table and Package table that essentially have two links between them, and there are two fields in the package table i.e. Parent and Child. THis design allows infinite amounts of nesting of parts into packages and packages into parts. I can decipher between a package and a part by a field in the parts table(by default everything is a part even if it is a package) called style. If style = 0 then it is a part, if style = 2 then it is a package. I am trying to generate a report that for each package i show all children, be them other packages or parts. Anyone ever done anything like this before, I need a shove in the right direction. Thanks in advance

Frank

 
You basically have two options here - the first is Crystal's built in solution to this situation - hierarchical grouping. This was first introduced in v8 (from memory). It allows you to define the field(s) that make up the parent/child relationship, then Crystal handles the 'nesting' from there. There are some limitations with this method...

The other option is to add your child table to your report repeatedly, and as many times as there are possible levels to the child/parent 'nest'. Each time you add the table again, Crystal will prompt for and use aliases to distinguish tables of the same name. You would then need to create a section for each level, and conditionally suppress the section if the level does not exist.

Hope this helps?!?

Peter Shirley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top