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

Printing the contents of different tables in one Report

Status
Not open for further replies.

Wendz

Programmer
Aug 9, 2000
47
0
0
PH
Visit site
Hello!

I have a new problem in printing the contents of the different unrelated tables, three tables to be specific in one report. I tested to have it in one report but it will display only the first record of each three tables. How I am gonna display all of its contents in one report? I can't combine them since the tables are having different contents they are only being linked by a primary...

Thank You very much for the help...

Wendz
 
Do you want table1 data then table2 data then table3 data? Try union queries. The structures will have to match to use union queries. Sometimes with very derverse data I dump them into two field queries. Field1 = table name. Field2 = MEMO w/ all the fields for that record.

If you want them combined, you have to find a way to relate them. Otherwise you will be writting three different reports
-Pete
 
Thanks Pete. Im having three tables related by autocode. This three tables are: 1st table consist of primary reponsibilities, 2nd table specific responsibilities and 3rd seminars attended. This three tables should be in one report with each table having separate fields on that report. Can I possibly copy those data to a memo? I'm not sure if what you suggest will be applicable woukld my problem. But I would try what you have suggested or you may have a better that would be best to solve my problem. Thanks a lot again and More Power to YOu.

Wendz
edbb@lycos.com
 
Sorry Wendz, forgot about this one. You have probably already resolved it but here goes anyway.

You have three tables all related on 1 field. Write a query joining each on the autocode field. Likely this will be a big query with lots of outputed fields. Most likely you want a LEFT JOIN from table1, then group by autocode, 2nd responsablities and lastly seminars in your report grouping. This will allow you to handle 1:Many relationship easily.

You may want to explicitly state which fields you want to see. If you have duplicate field names it can be a real mess otherwise.

Good Luck!
-Pete
 
If all else fails, use the old fashioned brute force method
[tt]
Use PrimaryResponsibilities
Copy stru extended to PriRes
use SpecificResponsibilities
Copy Stru Extended to SpeRes
Use SeminarsAttended
copy stru to SemAtt
use SemAtt exclu
append from SpeRes
append from PriRes
index on Field_Name tag field unique
set order to unique
copy to temp
use temp
create table Report from Temp
use Report
Append from PrimaryResponsibilities
Append from SpecificResponsibilities
Append from SeminarsAttended
Index as required
Report form xxxx to print
use
delete file PriRes.dbf
delete file SpeRes.dbf
delete file SemAtt.dbf
delete file temp.dbf
delete file report.dbf
delete file report.cdx
delete file report.fpt (if a memo field in any of the 3 tables)
Press on with life
[/tt]

needless to say this is off the top of my head programming, there maybe some syntax problems to repair. David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
Thanks you all for the tips. I appreciate it very much...

Wendz
edbb@lycos.com
 
Hi,

I want to do similar work. I have eight unrelated tables and want one report showing data from them.
I can try Pete's idea and have a table with TableName and TableData (memo) field.
Before I do lot of work in that direction. I want to find if this can be done in an array and then array can be bound to data report?
Otherwise I will have to create a 2 column table at runtime, dump 2 columns data, run report and drop table.
I am using vb6, data environment and data report.

Thank you all for this posting,
pjani.
 
If the three tables are related, and one table has the controlling field, open all three tables, set the reltionships, then use the primary table for the report. On the report, reference each by table.fieldname. And be sure to code for null/eof/not found values.

Or, just use the primary table, and in the init (data environment, right click) of the report, set procedure to a prg. In the prg, write functions to get the data that is needed from secondary tables. A caveat: each function need so set the environment back -- so always save the current work area as first line of each funtion, then as last line, set the work area back.

Or, create report variables for the othe fields, and in the prg, set them. Call the prg from the detail band (doble click on the band, then put the calling function in the 'on entry' box), being certain the reset the variables each time.

As always, in VFP, there are a myriad of ways to accomplish your goals!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top