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!

Random country function, how ? 1

Status
Not open for further replies.

petrovlis

Programmer
Jan 15, 2002
114
NL
I need to have in Cr10 Report a "function" that is
gving a random "destination country", say out of five
countries like :USA,Canada,Netherlands,Kuwait,India

I my mailing-letter I like to have a field which gives
just ONE, out of above five, as "random"
So first letter gives Canada,second letter,India etc etc
at random, in Report header, or detail section.
I send out mailings where I need this.
Thanks for any help.
William
 
Have a look at the rnd() function. I had to do this some time back and I pulled out some old code below. In the report header, put your array defining the countries:

Code:
WhilePrintingRecords;
StringVar Array Countries :=["USA","Canada","UK","Italy","Kuwait","India"];
Countries[1];

In some other section, put the random selection of the country, making use of the rnd() function:

Code:
WhilePrintingRecords;
StringVar Array Countries[int(rnd()*5)+1];

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Hi Thanks sofar,but I am rather a novice and wonder where
to put" the ARRAY defining the countries.: As a Formula
field making @countries and the code 1 and where to put the code 2, as what ...field,or ....

I tried for two hours, and with formula @countries I get
only the first "USA" not any other. meaning the "calculator" rnd function is not working,
due to the placing of the "formula" field ???
I put the code 1 in Pageheader as @countries.
and with the second code I am lost..
Thanks again.
 
Where do you want it to appear? This is where you place the 2nd formula.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top