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

range formula

Status
Not open for further replies.

ulicki

Technical User
Oct 24, 2001
88
US
Hi, I have the following formula in the Records Selection in a subreport. I use version 7 of Crystal.

ToText({crecap_view.NUF_GRANT_TYPE},0,"","") in {?Pm-@Make grant type paramater a text string for passing to the subreports};

NUF_GRANT_TYPE is type number and can only return values of 0,1,2.

The big long paramter is a text string. In the main report I ask the user to pass in a multiple value number parameter. Unfortunately CR 7 does not allow me to pass this directly to the subreport. So I parse this parameter out in the main report with the following formula which turns it into a string to pass to the subreport.

//this formula parses out the grant type paramater and makes it a text string for passing to the subreports
//in crystal 7 you cannot pass an array to a subreport
//chr(34) is the double quote "
//?Grant Types is the multiple value number parameter.

WhilePrintingRecords;
NumberVar elementsInArray := Count({?Grant Types});
Shared StringVar arraytext := "[" + chr(34) + ToText({?Grant Types}[1],0) + chr(34);
arraytext := arraytext + if elementsInArray >= 2
then "," + chr(34) + ToText({?Grant Types}[2],0) + chr(34)else "";

arraytext := arraytext + if elementsInArray = 3
then "," + chr(34) + ToText({?Grant Types}[3],0) + chr(34)else "";

arraytext := arraytext + "]";
arraytext;

So this formula returns ["0","2"] for example.

So my question is: Now knowing what the paramater string looks likes that is being passed to the subreport is my formula (the one at the top of the post) correct? Do you see any problems with it. I ask this because my original formula for the ToText formula, ToText({crecap_view.NUF_GRANT_TYPE},0,"","") did not have the ,0,"","" in it and it worked for me but not on my user machine. So I am trying to make this bullet proof. I am also concerned about the double quotes that surround my numbers in the string parameters I pass (["0","2']). Do I need them?

Thanks,
 
How are you using the shared variable? The subreport record selection is apparently using a parameter, not this shared variable, and I don't think that you'll be able to set a parm to this shared variable, especially in that format.

Just link the main report parameter to the subreport data, nothing else should be required.

-k
 
Hi synapsevampire,

Thank you for responding.

I am not sure why I used arraytext as a shared variable. I cannot remember what I was thinking at the time. Probably that I would pass the parameter as a string var shared variable instead of via subreport links.

Anyway, I pass this formula via the subreport links (rigt click on the subreport, and select change subreport links). I have printed the paramater in the subreport and the output is correct i.e. ["1","2"]. I think I do not need the WhilePrintingRecords or the SharedVariable as this formula can be evaluated before the WhilePrintingRecords pass.

Thanks,
 
That's correct, you don't need to code for this sort of thing, Crystal handles it.

-k
 
Hi synapsevampire,

What question of mine are you answering. If it is about the double quotes, is it OK to leave them in?

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top