Click here to Skip to main content
Click here to Skip to main content

Passing Parameters to Crystal Reports at Runtime

, 20 Nov 2003 CPOL
Rate this:
Please Sign up or sign in to vote.
Get and set the parameter value from the report


This article describes how to get and set the parameter value from the report:



This example is composed of:

  1. A sample report 

  2. A form that loads the report automatically and shows the preview report

  3. A button that retrieves the parameter's actual value using the method:

    private string GetParamValue (string paramName)
        string tmpValue="";
        for(int i=0;i<ReportDoc.DataDefinition.FormulaFields.Count; i++)
    						"{" + paramName + "}")
            tmpValue= ReportDoc.DataDefinition.FormulaFields[i].Text ;
        return tmpValue;
  4. Another button that changes the values of the report using the textbox text:

    private void SetParamValue (string paramName, string paramValue)
        for(int i=0;i<ReportDoc.DataDefinition.FormulaFields.Count; i++)
    					"{" + paramName + "}")
        ReportDoc.DataDefinition.FormulaFields[i].Text = "\"" +paramValue +"\"";


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) Claro Colombia
Colombia Colombia
German A. Fajardo G.
Web Developper
SQL Server Developer
PL/SQL Developer
Business Intelligence Desiggn Developer
ITIL Services Implementation.
Follow on   Twitter   Google+

Comments and Discussions

GeneralMy vote of 3 PinmemberJackson K T16-Aug-12 21:10 
GeneralMy vote of 5 Pinmemberpremkumar.r29-Jul-11 1:06 
GeneralMy vote of 2 Pinmemberinamgul26-Apr-11 21:48 
GeneralMy vote of 5 Pinmemberadnanrehmankhan19-Jul-10 1:02 
Generalchange the report's font at run time Pinmemberda_dhanaraj3-Nov-08 9:09 
GeneralExcellent! PinmemberBit-Smacker9-Sep-08 10:18 
Generalthanx Pinmembersajat29-Apr-08 3:05 
GeneralThanks Pinmemberzaider2-Apr-08 10:17 
GeneralThank PinmemberEscocia12-Jun-07 2:05 
GeneralWin Forms Grid Data and more PinsussAnonymous11-Apr-05 0:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411023.1 | Last Updated 21 Nov 2003
Article Copyright 2003 by gfajardo
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid