Crystal Reports
Google
Web www.mahipalreddy.com

 

How do I Loop through a multiple Valued Parameter in crystal reports ?
How to display a multiple Valued Parameter using crystal syntax?

Multi valued parameters in Crystal reports allow the users to enter more than one value into the parameters.

'Code by Mahipal Padigela
'The example uses BASIC SYNTAX, so make sure you change the syntax type in formula editor
'Create a formula in your Crystal Reports 
'Paste the following code into the formula window
Dim X As Number DIM S AS STRING x=1 FOR X = 1 TO UBound({?City}) if X = 1 then S = {?City}(X) else S = S + ", " + {?City}(X) end if NEXT FORMULA =S

Top

How to use SELECT CASE expression in formulas and Record Selection formula - Crystal Reports ?

The Select case expression is similar to an If expression. Sometimes however, you can write clearer and less repetitive formulas using the Select expression. The code sample uses Crystal syntax.

//Code by Mahipal Padigela
//Create a formula in your Crystal Reports
//Paste the following magic code into the formula window

	Local StringVar message;
	Local CurrencyVar bonus;
	Local CurrencyVar sales:={Customer.Last Year's Sales};
	select sales
		case Is > 15000 :
		(
			message := "Excellent sales!";
			bonus := (sales * 5)/100;
		) 
		case 10000 to 15000 :		//specify ranges like this.....
		(
			message := "Good sales!";
			bonus := (sales * 3)/100;
		) 
		Case 8000, 9000, 9999 :	//specify multiple values like this....
		(
			message := "Not bad!";
			bonus := (sales * 2)/100;
		)
	
		Default :
		(
			message := "Poor sales";
			bonus := (sales)/100;
		); //The preceding semicolon is required to separate the If expression from the final expression below
		
		message & " your bonus is " & CStr (bonus)

Top

How do I use IF Else expression in formulas and Record Selection formula - Crystal Reports?

The If expression is one of the most useful control structures. It allows you to evaluate an expression if a condition is true and evaluate a different expression otherwise.The code sample uses Crystal syntax.


//Create a formula in your Crystal Reports
//Paste the following magic code into the formula window

	Local StringVar message;
	Local CurrencyVar bonus;
	Local CurrencyVar sales:={Customer.Last Year's Sales};
	
	If sales >= 15000 Then
	(
	   message := "Excellent sales!";
	   bonus := (sales * 5)/100;
	) 
	else If sales >= 10000 and sales < 15000  Then
	(
	   message := "Good sales!";
	   bonus := (sales * 3)/100;
	) 
	Else
	(
	   message := "Poor sales";
	   bonus := (sales)/100;
	); //The preceding semicolon is required to separate the If expression from the final expression below
	message & " your bonus is " & CStr (bonus)

Top

Why do I get crystal Reports error: A loop was evaluated more than the maximum number of times allowed ?
How do I set the maximum number of times a loop can execute in Crystal reports ?
How do I use the Option Loop statement in Crystal reports ?

There is a safety mechanism in crystal reports to prevent report processing from hanging due to an infinite loop. Any one evaluation of a formula can have at most 100,000 loop condition evaluations per formula evaluation. The code sample uses Crystal syntax

The Option Loop statement can be used to specify the maximum number of loop condition evaluations per evaluation of a formula.
The Option Loop statement must be used before any other statements.

	//option loop example
	option loop 256; //specify the maximum number of loop condition evaluations
	//example converts Customer.Customer Name to upper case
	Local StringVar outString;
	Local StringVar inString := {Customer.Customer Name};
	Local NumberVar i;
	For i:=1 to Length(inString) do
	outString := outString + upperCase(inString[i]);
	outString

 

If Customer.Customer Name is greater than 255, an error message will be shown: A loop was evaluated more than the maximum number of times allowed.

Top

www.mahipalreddy.com
Terms and Conditions of Use
Copyright 2004 - 2006 Mahipal Padigela. All rights reserved.