cancel
Showing results for 
Search instead for 
Did you mean: 

How to suppress decimal part for numeric fields dynamically

Former Member
0 Kudos

Hi ,

We are using Crystal Desinger of version 11.5.0.313.

We have numeric fields whose format is picked up fromt he systems regional and language options settings. This approachis working for numeric fields with decimal values. But it is failing in the case of numeric fields which should not diplsya decimal part.

The system numeric format is set as below :

Decimla Seperator : "#"

Thousand Seperator :"!"

eg if the value of the field is "12345", becasue of the system format the value is displayed as "12!345#00" But we are expecting "12!345"

The moment we try to customize by saying the decimal as "1" the fields is not picking the thousand seperator from the regional settings at runtime.

Can you please help us how we cans uppress decimal places at runtime ?

Thanks in advance.

Thanks and Regards,

Shireen.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Seem issue so same solution

Try this and see if it works for you.

ToText({database field},0,'!','');

// 0 = No Decimals

// ! = the thousands separator

// '' (two single quotes with no spaces) = no decimal separator

Edited by: Sanjay Kodidine on Feb 12, 2009 5:27 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Shireen Ganni

To avoid taking numeric formatting from your regional settings, open crystal designer and go in FileOptions-select FieldsUnder fields select Number and go in Number Tab here you specify the format which you would like to apply.

This will take all your number fields in the specifyed format.

Thanks,

Sastry

Former Member
0 Kudos

Hi Sastry,

Thank you for your inputs. We have two types of numeric fields.

1. Numeric fields which are just whole numbers without decimal values

eg : NO of files -- 100500

2. Numeric fields like Charge which have decimal values

eg: Product charge : 11250.50

So I need to specify data format for each of its kind differently. Also it has to pick the decimal seperator and thpousands seperator at runtime dynamically from the regional settings which is not happening currently for whole number numeric fields.

Thanks in advance.

Thanks and Regards,

Shireen.

Former Member
0 Kudos

By custom formatting the numeric fields you'll then not be able to set the formatting to "System Default Number Format"

AND I suspect that custom formatting you're doing does NOT fit with the system default formatting.

You can't have "System Default Number Format" AND custom formatting simultaneously.

Former Member
0 Kudos

Hi James,

Thank you for your inputs.

Does it mean that I cannot have fields of numeric field with out decimal and numeric field with decimal in a report ?

Please suggest if I am missing something here.

Thanks and Regards,

shireen.

Former Member
0 Kudos

Can't you just reduce the number of decimal places for the field? Crystal defaults to two decimal places for numeric fields, but you can change that to however many places that you want. There's a toolbar button to do this, or you can right-click on the field, select Format Field, and under Number there are options to reduce the decimals to zero.

HTH,

Carl