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

Expanding "Print When" or Expression window

Status
Not open for further replies.

WayneBecker

Programmer
Nov 29, 2000
20
CA
Is there any way to have an expression greated than the "Print When" or "Expression" windows when using the Reports Generator? Thanks...........Wayne
 
Thanks for the prompt reply. What I was trying to ask is; is there any way to have an expression greater than the 256, or whatever the count is, of the present content of the "Print When" or "Expression" boxes associated with a report? The logic I am thying to use does not fit in the number of characters that fit in the box.

Thanks again...............Wayne

 
Waynebecker

Yes you could use a custom class. You create a function that does whatever you want and I returns a true or false, which you would check it the print when.
If you need more explanation, let me know.
 
Wayne

I figured I would explain a little further what I meant with the above suggestion. Lets say you have a custom class that contains a UDF that calculates records in a cursor and if the count is 0 your don't want a certain piece of information to appear on your report, if the count is above 0, make it appear.

1. Create a report, and a textfield on it and in the expression put : lVal=oFunc(CheckPrintWhen)
And in the printWhen chekc for the value of lVal
2. Create you custom class:
Code:
DEFINE CLASS myfunction AS custom


	Name = "myfunction"


	PROCEDURE checkprintwhen
		SELECT Expenses_2.inv_no, Expenses_2.date, Expenses_2.unit_no,;
		  Expenses_2.type, Expenses_2.cost;
		 FROM maintenance!expenses_2;
		 WHERE Expenses_2.date BETWEEN dat1 AND dat2;
		 ORDER BY Expenses_2.date;
		 INTO TABLE "c:\maintenance\tempdata\cost summary.dbf"
		 INDE ON UNIT_NO+DTOS(DATE) TAG WIZARD_1
		 INDE ON UNIT_NO TAG WIZARD_2
		 count to nRec
		 
		 IF nRec = 0
		   RETURN .f.
		 ELSE
		   RETURN .T.
		 ENDIF
		 
	ENDPROC


ENDDEFINE

And before you run your report use:
oFunc = CREATEOBJECT("myFunction")
report form myReport.frx
And as the report loads the function will kick in. Unfortunately the debugging of the function is difficult. The function should be tested outside of the report.
 
Thank-you for the detailed reply. Does the procedure calculate the answer before calling the report or does it do it as each record is passed to the report? My problem is that it has to decide whether to print each line in the report, "Print When", or decide what the answer to the expression is as it prints each line.

Thanks...............Wayne
 
Every textbox that contains this function call will recalculate the answer as the report is being processed, not before.

 
Thank-you very much for your great help and patience.

Thanks.......................Wayne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top