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!

How do I make a report from a query, view or cursor?

Status
Not open for further replies.

grazbukanoff

Programmer
Apr 25, 2002
2
0
0
ES
Hello,

I am very new to FoxPro and programming in general. I am making a school database and I have created a query called MARKS, which contains fields from different tables.

I would like to know how I can create a report from this query. The manual says soemthing about cursors and views. I have managed to make output the query data as a cursor. How can i use this cursor to make a report from the query?
 
Here is a sample of what you want to do

SELECT Sinancil.timepoint, Sinancil.testname, Sinancil.testresult,;
Sinancil.convert, Sinancil.visitnumbe,Sinancil.method,Sinancil.cost,;
Sinvisit.name, Sinvisit.tdate, Sinvisit.patient,Sinvisit.studynumb,Sinvisit.instructio2;
FROM sinancil LEFT OUTER JOIN sinvisit ;
ON Sinancil.visitnumbe = Sinvisit.visitnumbe;
INTO CURSOR UNO;
WHERE Sinancil.visitnumbe = ?cParametroDeVista;
ORDER BY Sinancil.patient, Sinancil.testname, Sinancil.timepoint
REPORT FORM nTESTS NOCONSOLE TO PRINTER PROMPT
 
ADJOE,
I'm not sure that your example explain how to make a report from a cursor. I think it show how to use a report with a cursor, but I think the report (unless it already exists), still needs to be designed.
 
Hi grazbukanoff,

Cursor is Temporary Table from query. When you close the cursor table, VFP delete it. When query finish, the cursor is available to View, Browse, Report it, etc.

This is a simple example:

SELECT *;
FROM Tickets;
WHERE Tickets.asigned LIKE "%TEST%";
INTO CURSOR Asign
select asign
REPORT FORM <reportname> NOCONSOLE TO PRINTER PROMPT

You can define the fields into the Report like when you use a Table.

Best regards from Panama,

Marlon
 
grazbukanoff

Since a cursor is not really a table, you cannot put it in the DataEnvironment of the report, and you cannot select the fields in the expression builder. Once you created you cursor, just use:
Code:
SCATTER MEMVAR
And create a blank report, and when you put a textbox on the report you can now see the fields of the cursor as a variable (of the left hand side of the expression builder)
 
Thank you mgagno. I see that the SCATTER MEMVAR makes the cursor available as any other table for a Report. However, is this table temporary or do I have to delete it manually?
 
No you don't have to delete it manually.
1. Just select your cursor (to make sure it's the current Alias())
2. Run your report
3. Close out the report and the cursor goes out of scope (get destroyed by itself)
 
I'm kind of confused about something. If I have a button on a form that creates the cursor(below) and runs the report where do I put scatter memvar?

select * from a_artran where allt(la_arcust(1,Ai_custno))=allt(a_artran.custno) group by item into cursor query1
report form &quot;s:\p\ar\profiles&quot; preview for allt(la_arcust(1,Ai_custno))=allt(a_artran.custno) noconsole
 
Kerbouchard,

If I've understood this right, you don't have to do the SCATTER MEMVAR in your application. I think Mike Gagnon's suggestion was to do it while you are developing your report, so that the field names become visible in the expression builder. (He will correct me if I've got that wrong.)

Mike

Mike Lewis
Edinburgh, Scotland
 
Mike I don't know what I was thinking. The data wasn't pulling for me because of something else I was doing. thanks for the response!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top