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!

How do I include two tables in a report? 1

Status
Not open for further replies.

ejhemler

Programmer
Aug 30, 2002
68
US
I need to create a report that references fields from two different tables. I can't figure out how include these fields in the table. It will only let me choose fields from one table. Whenever I reference a field from a different table, it says that it could not find the alias of the table that is not currently being used. Should I create a temporary cursor file?, and if so How do I do this? Sorry if I am asking a lot but I have only been working with this for a few weeks.

Erik
 
I would suggest creating your report with a cursor or table, created from the two tables:
Code:
SELECT tableA.field1, tableA.field2, tableA.field3, ;
       tableB.field1, tableB.field2, tableB.field3 ;
   FROM tableA, tableB;
   WHERE tableA.field1 = tableB.field1 ;
   INTO CURSOR SomeCursor

Just remember to use only the field names and don't include aliases of any of the tables when designing the report, and it will make life a lot easier.
Also remember that if the field names are the same in both tables, Fox will rename them in the cursor to something like Field1_a etc. So you may want to specify your own field names:

SELECT tableA.field1 AS First , tableB.field1 AS Second....
Dave S.
 
I do not intend to be condescending so I will offer apologies early on, but from your question it is unclear how much you understand about Foxpro.

First I assume that you know how to simultaneously open 2 (or more) tables into different workspaces at the same time. If not, then you need to study how Foxpro works.

Continuing with the above assumption - I also assume that the information in the records of the 2 tables is somehow related to one another. Further I assume that you know how to set up a Relation between 2 or more tables.

Establish a Relation between table 1 and table 2. When you do that, when you "point" to Table 1 - record n your program will be able to "see" the contents of the related record in Table 2.

Another possible approach would be to bring together all desired information from the 2 tables into a single table or cursor with a SQL Query and then present the resultant table to the report.


Good Luck, JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Hi Erik! I don't know if that can help u but i'm used to create reports that reference fields from 2 or even 3 tables by using the RQBE query dialog. U just have to open the necessary tables n choose the required options n it's done. It also gives u the facility to generate a quik report, which u can format afterwards. I find it very handy n hope so for u. The SQL commands are generated by the query itself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top