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!

Multiple detail tables in a VFP report

Status
Not open for further replies.

cobbycoker

Programmer
Nov 20, 2002
7
GH
Hi all,

Without a grid control on the VFP report writer controls, is it possible to show details from more than one table in the detail band?

I have a master table with 2 related detail tables, and I'm trying to write a report which will show the details, gridlike, one after the other.

Any pointers?

Thanks

Cobby
 
cobbycoker,
This has been posted in a newsgroup:
Code:
How to do a Multi-child FoxPro report:


*!* Create a cursor with fields from the parent and each of the children
*!* Include a Field called RecordType
CREATE CURSOR ReportCursor (....)

*!* SCAN through the parent table
SCAN && FOR some criteria
	
    *!* Get a clean set of all variables
    SELECT ReportCursor
    SCATTER MEMVAR MEMO BLANK

    *!* Make the parent variables available for each row
    *!* m.PrimaryKey is the parent table's PK
    SELECT ParentTable
    SCATTER MEMVAR MEMO
	
    *!* Get matching records from Child!
    SELECT Child1
    m.RecordType = "Child1"
    SCAN FOR Child1.ForeignKey = m.PrimaryKey
        SCATTER MEMVAR MEMO
        SELECT ReportCursor
        INSERT INTO ReportCursor FROM MEMVAR
    ENDSCAN
	
    *!* Just in case,
    *!* Clean out Child1 memvars
    SELECT Child1
    SCATTER MEMVAR MEMO BLANK
    *!* Rescatter Parent memvars
    SELECT Parent
    SCATTER MEMVAR MEMO
		 
    *!* Get matching records from Child2
    SELECT Child2
    m.RecordType = "Child2"
    SCAN FOR Child2.ForeignKey = m.PrimaryKey
        SCATTER MEMVAR MEMO
        SELECT ReportCursor
        INSERT INTO ReportCursor FROM MEMVAR
    ENDSCAN
	
ENDSCAN && Get next Parent record


In the report, put the parent variables in the group header or page header.

Group on PrimaryKey and again on RecordType?.

Put column headers in the group header with "Print when" set to look at the record type. They will probably be on top of each other!

In the detail line you need all of the fields for each record type, again with "Print when" related to the RecordType?. Again, they will probably be on top of each other!

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first or check this link
 
Thanks Mike, I'll try that out. Why don't they put a grid control on the report writer?

I miss my Paradox!

Cobby

 
Mike, I like the Excel solution. I can open Excel directly in print preview after formatting the report. However when you close the print preview, it leaves the Excel window open. Can I prevent this? I want the user to either print or close the report from print preview without having to bother with the main Excel window.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top