Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing variables to report
Message
From
21/11/2002 12:23:13
 
 
To
20/11/2002 21:02:53
Yh Yau
Ingenuity Microsystems Sdn Bhd
Kuala Lumpur, Malaysia
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00722790
Message ID:
00725326
Views:
39
Yau,

I just couldn't let this problem beat me.

This solution requires a report with a private dataenvironment, because the users will be previewing the reports with a NOWAIT clause. The question is how to get persistant information into the report. Private created from a form variables don't work...they are not visible from the report when the user pages down to another page from the preview window.

Here is incomplete code to invoke the report from a form. A copy of the report is made...this allows the user to preview the multiple copies of the same report (with different parameters) simultaneously. You'll have to come up with a way to track the temporary report files, and to clean them up later.
* code from form to launch report preview
private lnMaxBuyerID

lnMaxBuyerID = thisform.text1.value

lcReportSource = "testReport"
*  this is the temporary file name the report is copied to...in practice you would 
*      not want to create this file in the current folder...probably want to put it
*      in temporary file location
lcTempReport = SUBSTR(SYS(2015), 3, 10)

copy file (lcReportSource + ".fr?") to (lcTempReport + ".fr?")

report form (juststem(lcTempReport)) preview nowait
In the init() method of the report's dataenvironment, create a one record cursor to hold the report parameters (for printing on the report header, for example), and create a report cursor that contains that data that is printed in the body of the report. Interesting sidebar, in playing with this, I observed that opentables() and beforeopentables() methods fire on *every* page of a report...so neither of them are a good place to put this code. Here is a simplified example:
* init() method of report dataenvironment
nodefault
dodefault()


if vartype(pnMaxBuyerID) <> "U"
	create cursor reportParameters (maxBuyerID i)

	insert into reportParameters (maxBuyerID) values (pnMaxBuyerID)


	select * from buyers where buyerID <= reportParameters.MaxBuyerID into cursor reportCursor
	select reportCursor

endif
I hope I didn't leave anything out. Let me know what you think...

>Steve,
>Thanks for the insight.
>Guess I'll have to look beyond the VFP report writer for my solution. Probably Crystal (again...) :-)
>Yau
Steve Gibson
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform