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

Dumb ? # 2 - Reports & Relations

Status
Not open for further replies.

FAC17

Programmer
Jan 24, 2002
26
US
Old dbase programmer struggling with FoxPro 6....

I have a simple form that needs to display info from two tables.

2 tables from an established dbc in Data Environment.

Order set for both tables

drag and drop relation - properties looks okay.

Can't get information for child table to display in preview although parent table info is fine.

I can do this from the command window with no problems so indexes are okay. I can also make it work if I set up the tables, indexes and relationship in the command window and then preview the form but I would like to know what I am doing wrong with the data enviroment.

Thanks for your help!!!!!

FAC
 
I should have said that is a REPORT not a form in case that changes your response!

Thanks!

FAC
 
Hmm...I've never used the DataEnvironment in a report, so I'm not sure. All of my reports use a .PRG to bring up the data set and then run the REPORT with the right table selected.

Odd question for you...did you maybe reverse parent and child tables when you made the drag-drop relationship? Double check the ParentAlias and ChildAlias properties of the Relation object (click the black line).

Ian
 
I have used the DataEnviornment in a very few reports. In each case I set a group header with information from the "primary" table and placed information from the "related" table in the Detail band. I put totals and whatknot in the Page Footer. (don't know what your table names are so put in the quotes).

This is the only way I have found to go through the primary table and show info for the child table.

 
HI
1. In the report, make the child table as the default alias selected.
2. Set the relationship.. child to parent.. instead of parent to child.
3. The data grouping shall follow your required choice of fields on the child table.

This shall fix your problem :) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Thanks everyone for the responses! I got it to work with Ramani's suggestion.

Also - when I added a third table I hooked up the relationship in what I consider the normal way (parent to child) and the third table was correctly controlled by the parent.

Ramani, Do you know why this works this way? It is not only the reverse of my experience with older version and the reverse of what works in the command box but is also intuitively bassackwards!

Just curious

FAC
 
I think I can actually explain this.

A report is based on detail. The basic unit in the report is a single record. Since in your detail you are printing one line per record in the child table, the main table needs to be the Child table.

Since there are some fields that need to be printed from the parent table, you will need the parent table's record pointer to move when the child table's related field changes. To accomplish this, you need to set a relation from the child table back into the parent table.

Reports are not capable of printing from multiple records in a single line of detail. To do it the normal way, you would iterate through the parent table and print records for each child that corresponds to the parent record. VFP Reports cannot do this. Instead, you go the other way: iterate through the child table so there is only ever one record to pull data from.

Does that help you understand?

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top