Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

7.05 Assigning Variables

Variable Assignment

After creating a variable, you need to assign a value to it. This can be a simple constant, a data field, or the result of a more complex calculation. The key thing to remember is that the data types on both sides of the assignment must be the same. For example, you can’t assign a string to a DateTime variable. Crystal Reports gives you an error when it sees this. You either have to reconsider the validity of what you are attempting to do, or use a type conversion function to make the two compatible.

Crystal syntax uses := to assign a value to a variable.

X := 5;
Y := “Mr. ” & {Customer.Last Name};