0
votes

I have a report that displays different rates for different items. One of these items is "mileage" and has a rate that has fractional cents (0.565).

We want to display the full 0.565 for these rates, and show all other rates with two decimal places.

To facilitate this, I used a formula in Format Field > Number > Customize for both Decimals and Rounding that looks basically like this:

if({RATE_TYPE}='MILEAGE')then 3 else 2

This appears to be working correctly in Crystal Reports. For mileage, 3 decimal places are shown, and it is rounding to 3 decimal places.

In Crystal Reports Viewer (and subsequent exports), it is showing 3 decimal places but it is rounding to 2 decimal places.

I am using Crystal Reports 2008 (12.3.0.601), and Crystal Reports Viewer:

<system.web>
  <sectionGroup name="businessObjects">
    <sectionGroup name="crystalReports">
      <section name="rptBuildProvider" type="CrystalDecisions.Shared.RptBuildProviderHandler, CrystalDecisions.Shared, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null"/>
    </sectionGroup>
  </sectionGroup>
  ...
  <compilation debug="true" defaultLanguage="c#">
    <assemblies>
      ...
      <add assembly="CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      <add assembly="CrystalDecisions.Enterprise.InfoStore, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      <add assembly="CrystalDecisions.ReportSource, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      <add assembly="CrystalDecisions.CrystalReports.Engine, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      <add assembly="CrystalDecisions.Shared, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      <add assembly="CrystalDecisions.Enterprise.Framework, Version=12.0.1100.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
      ...
    </assemblies>
    <buildProviders>
      <add extension=".rpt" type="CrystalDecisions.Web.Compilation.RptBuildProvider, CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
    </buildProviders>
  </compilation>
  ...
  <httpHandlers>
    ...
    <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
    ...
  </httpHandlers>
  ...
</system.web>
<system.webServer>
  ...
  <handlers>
    ...
    <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
    ...
  </handlers>
  ...
</system.webServer>

(sorry about the wall of code)

Has anyone encountered this before? Is there a known fix?

1
What is your default value for the decimal places?campagnolo_1
The values in the drop-downs are 1.00 and 0.01, I'll change those both to three-digit values and see what happens.Shmiddty
You will have to in order for it to workcampagnolo_1
That doesn't explain why it is working correctly in the report previewer inside of the Crystal Reports editor.Shmiddty
I can't answer why it works in Designer but not in the Viewer, I just know that you have to set the defaults to the maximum you want to achieve and then use a formula to change it dynamically.campagnolo_1

1 Answers

1
votes

You will need to set your default values for decimals and rounding to the maximum amount you are trying to achieve. So in your case it would be 3.