Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One to Many, Parent-Child reporting
Message
 
 
To
27/04/1999 19:07:57
Ernie Veniegas
Micro System Solutions, Inc.
Calistoga, California, United States
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00212807
Message ID:
00212835
Views:
27
The main idea is to get your cursor to look like what the report format should be. In the below example you could create a "fake" field that holds the child type.

In the simplest situation where you have a parent, child and grandchild you would do a SELECT to get data together into one cursor, then use the groups feature in the report to create each "band"

cParent - parent table
cChild - child table
cGrandchild - grandchild table

SELECT cparent.*, cchild.*, cgrandchild.* ;
FROM cparent, cchild, cgrandchild ;
WHERE cparent.id = cchild.id AND child.id = cgrandchild.id ;
order by **whatever**
INTO cursor cReport

.. then send to report

The above would allow any number of "generations" in a report

PARENT
..CHILD
...GRANDCHILD
PARENT
..CHILD
(and so on)

In the case that you have two different child tables you would do the following. You would need to ensure or force the two child tables to have the same number, type and size of fields.

SELECT cparent.*, "TYPE1" as rtype, cchild1.* ;
FROM cparent, cchild1 ;
WHERE cparent.id = cchild1.id ;
UNION;
SELECT cparent.*, "TYPE2" as rtype, cchild2.*
WHERE cparent.id = cchild2.id ;
INTO CURSOR cReport

... then send to report (Note: one of the groupings would be by "rtype"

The above allows any number of child records to be group (if expanded.

PARENT
..CHILD1
..CHILD2
PARENT
..CHILD2
PARENT
..CHILD1
(and so on)

Does this help?

>I have a situation where I've got a tables engaged in one-to-many parent-child table relationships. The children themselves are parents with many child relationships of their own. The way I've handled simple, single level one-to-many reports in the past is put the fields from the parent into one report band, and the fields from the children in the detail band. But how do I go about doing two or three tiers of this?
>
>Let me try to explain this another way.
>
>PARENT
>...One-of-Many-Child-Type-1
>........One-of-Many-Child-Type2
>........One-of-Many-Child-Type2
>........One-of-Many-Child-Type2
>
>........One-of-Many-Child-Type3
>........One-of-Many-Child-Type3
>........One-of-Many-Child-Type3
>
>...One-of-Many-Child-Type-1
>........One-of-Many-Child-Type2
>
>........One-of-Many-Child-Type3
>........One-of-Many-Child-Type3
>
>...One-of-Many-Child-Type-1
>........One-of-Many-Child-Type3
>
>...One-of-Many-Child-Type-1
>........One-of-Many-Child-Type2
>
>
>What I need is a list of the Parents. I figured I put this in its own report band. But after each parent, what I can't figure out how to do is list fields from all the Type-1 records, followed by its children Type-2 and Type-3 records. Does this make sense to anyone and do you have any suggestions on a technique to make this happen? Help! I'm stumped.
>
>Please and thanks for the help.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform