Using Variables Within Crystal Report Formulas
page 1 of 6
Published: 27 Apr 2010
This article demonstrates how to create formulas in a Crystal Report and use the Crystal scripting language to create variables, use built in functions, perform conditional logic, and manipulate dates. After a brief introduction, the article provides the steps required to create the database, the website, and the report, including how to add fields and formulas to the report. Near the end, the article examines the steps required to create formulas with variables.
by Vince Varallo
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 79546/ 75


Formula fields within Crystal Reports allow you to inject code blocks within a report when simple Select SQL statements can't do the trick.  You can declare variables, create if-then blocks, create arrays, execute loops, or call built in functions within Crystal Reports.  This article will create a Crystal Report in an ASP.NET web site project and demonstrate how to create a formula field, manipulate a date in the formula as well as elaborate on how to declare a variable and assign it a value, and also use if-then logic to create summary fields by quarter on the report.

Before you begin you will need to have installed Visual Studio 2008 with Crystal Reports for .NET.  The samples are written in Visual Studio 2008 but they will work with Visual Studio 2005 also. I created a simple database with one table to use for the sample report. The code for the sample report created in this article can be found here.

View Entire Article

User Comments

Title: Very goo   
Name: Shivayogi
Date: 2011-09-08 11:26:19 PM
This code is helped me a lot
Title: Formula fields in Crystal Reports   
Name: Esha
Date: 2010-07-01 3:11:46 AM
Very Good and useful example
Title: Surge Consulting Group   
Name: Surge Consulting Group
Date: 2010-05-07 4:14:41 PM
Very very cool! Thanks for the example!
Title: Using Variables Within Crystal Report Formulas   
Name: pavani
Date: 2010-04-28 3:22:02 AM
simple and easy to understand article.When i tried to add crystal report template in my vs2008 i could not find it so do i need to restall my vs 2008 ?

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-06-23 9:14:23 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search