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!

Changed field format in designer

Status
Not open for further replies.

PRMiller2

Technical User
Jul 30, 2010
123
Good morning,

I am new to Crystal Reports so please bear with me. I have a C# project designed in Visual Studio 2010 Professional Edition with Crystal Reports embedded. I created a report with about 20 fields, and populate the values at run-time with a data-table.

My question is this: I believe the fields were created as string fields. The majority of my fields are numeric, and should be formatted without decimal places. In the design view of the report, I have changed the decimal places to 0. However, at run-time, the report still displays as 0.00. Also, I can right-click on the field and select format, but I don't have an option to format as 0 -- leading me to believe that I created the origianl fields as strings.

How can I change the fields to numeric so that I have formatting options?

Thanks,
Paul
 
You can replace the string fields with formulas where you wrap the field in tonumber():

tonumber({table.numericstring})

You could, if you wished, then reformat them in the formula:

totext(tonumber({table.numericstring}),0,"") //no commas ("") or decimals (0)

But if you want to work with the fields as numbers, you are better off just converting them to numbers and then formatting the display to show no decimals.

-LB
 
I see. Assuming that is done programmitically, would you recommend creating a method that loops through the appropriate fields, then calling that method from here:

Code:
public virtual CrystalDecisions.CrystalReports.Enginge.ReportDocument CreateReport() {
     VOCEmissions rpt = new VOCEmissions();
     // Formatting method called from this line?
     rpt.Site = this.Site;
     return rpt;
}

Thanks,
Paul
 
Sorry, this is outside my area of expertise. Maybe someone else will respond.

-LB
 
No worries. With the solution you posted, where I should I enter this formula?
 
Create the formulas in the field explorer->formula->new and then use the formulas in place of the fields on the report.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top