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!

reports 2

Status
Not open for further replies.

Alexb0725

MIS
Jun 9, 2021
6
PH
Good day Guru
I would like to ask for your help since I'm new in programming in VFP and I'm using VFP 9. I'm creating a report using 3 dbf files. When I used the report wizard I can only use 2 files but my reports needs all the three files to accomplish the required report.
My first table is the master table and one of the field is payee, then the payee will get some information like address and telephone number on the second file and also in my master table I do have ATC fiel and it's description will get in the 3rd table. the description is in the memo field.
Hope you understand my problem and help me to solve it.
Thank you very much
 
What did you try and where is your problem?

A report is driven by one major workarea, (typically in the same datasession as the code executing the report).

To use multiple tables you either prepare one single result with SQL and joins - there is no limit of joins so two detail tables are no problem. Or you set relations:

Code:
SELECT detail1
SET ORDER TO TAG tagname1

SELECT detail2
SET ORDER TO TAG tagname2

SELECT master
SET RELATION TO field1 INTO detail1
SET RELATION TO field2 INTO detail2 [b]ADDITIVE[/b]

I think ADDITIVE is what you didnÄt know and thus could only set one relation to either detail1 or detail2. Well, the hep has a reference for every class/function/command.

Are you using the dataenvirononment of a form which executes the report? Or the dataenvironment of a report? There is no problem creating two relations from one table to two others visually, you just drag the field of master to the corresponding index in the detail table.

Chriss
 
Hi Alex,

Every report in VFP has a so-called driving table, that is, a table (a DBF file) which provides the main source of data for the report. The records in that table are processed sequentially while the report is rendered, and each record then provides the data for the detail band of the report. (I'm over-simplyfing this.)

In your case, you have three tables. You master table will be the driving table. To get the data from the other two tables into the report, you have two options. You can set relationships from the master table to each of the other two, as shown by Chris, above. Then, as each master record is processed, VFP will automatically bring in the data from the related records and make these available for the report.

Alternatively, you could combine the three tables into a cursor (a temporary table, created just for the purpose of the report). For the latter, you would usually use a SELECT - SQL statement. Personally, I would go for that latter approach, but it assumes you have some knowledge of SQL (or are willing to learn).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Good day!!!
Thanks sir Chris, I will try your code.
Sir Mike thank you for your reply and yes I'm willing to learn SQL
 
Good day!!!
Sir Chris, I can't really get what I wanted in my report can you help me please?
thanks a lot.
 
That's what the forum is for, but there's not much more to tell you when you don't get more concrete about your problem.

As Mike said there's generally one table (workarea/alias) driving the report. The report engine goes through it from top to bottom, sometime filtered by a FOR clause. So one way to get your report is to first get the data you want to print into one table in the order of printing it and then wrap a report around that data.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top