A True Coding Solution

I have a bespoked purchase order print which uses an integer loop to print off two types of purchase order (internal and external). The user needs the option to only select one or the other of these prints, I could copy the report and then run either from a menu option, but what I would like to do is pass a variable through to the report to select the type of print. Could this be done by creating some kind of function with a local variable to pass on the report? or is it not possible? Thanks

HI ANDREW, You can give the Select option on the option Tab of Request form for internal and external . If it is option Button then it will pass the value to your report whether it is external or internal. is this of any help ?

Thanks, that solution would work just fine. Out of curiosity through is it possible to pass a variable through to a report before running.

Andrew Yes it is possible to pass parameters to a report before running the report. It would the report you want to run would have to be defined and run as a variable. You would create a function ‘SetParams’ on the report and before you run the report you would need to run the function VARs GRep Type Report CLEAR(GRep); Rec.SETRANGE(FieldA,FieldA); Grep.SETTABLEVIEW(Rec); Grep.SetNoOfCopies(AnyInteger); Grep.RUNMODAL;

Hi, While Stephen’s solution may work when the variable is related to the record you are running the more generic way of passing variable to a report is: 1. Create in the report global variables that you want to initialize with your values, say Param1, Param2, a.s.o. 2. Create a function in the report, say SetParams(NewParam1Val,NewParamVal2,a.s.o) Param1 := NewParam1Val; Param2 := NewParam2Val; 3. In the code calling the report you do: clear(RepToRun); RepToRun.SetParams(Val1,Val2); RepToRun.RunModal(…); Hope this helps. Regards, Cristi Nicola.

Thanks for all your help

But what can you do if the user can define the report, and you have to use report.run(table.reportID,False,False,Rec)

You need to provide this function and global variables on all reports the user may enter into this table. If this is a report which gets started from some form (e.g. Purchase Order), the report will have to be related to the underlying table in some way, so only certain reports will make sense. For these reports, you will have to implement the above mechanism. Yeah, posting number 500. Here comes star number 4. Yes, I know, I know… [;)]