Numeric parameters without commas

Monday 21 June 2010 @ 12:04 am

It is very easy to change the format of numeric fields that appear on the report.   Even a numeric parameter that is placed on the report can be formatted just about any way you can imagine.  But for some reason the format of a numeric parameter “List of values” (LOV) is much more difficult to control.  Users get annoyed when a numeric parameter input for an account number or some other numeric code is formatted with commas and (in some cases) decimal points.

In most versions up through v10 there was one less-than-ideal way to control of the format of numeric parameter lists:

1)You went into File > Options and selected the “Field” tab.
2) You clicked the “Number” button and the “Number” tab.
3) You selected the format you wanted (or went into “customize” to create the desired format).

The problem with this method is that it affects ALL numeric parameter inputs in all reports on this PC.  It also affects how any new numeric fields will be formatted when the are first added to the report from the Field Explorer.   And since this is a local setting, it only works on the local PC.  Move the report to another PC and the format you have set will revert to settings on that PC.

And starting with v11 even this bit of control seems to have gone.  Making the change described above still changes the format for new numeric fields placed onto the report, but it seems to have no effect on the input format for a numeric parameter.  In versions 11 and 12 I could not find a way to control the formatting of a numeric parameter which now has commas and no decimals.

The only workaround I can think of is to use a string parameter and convert it to number in the selection formula.  This get’s tricky if the parameter allows multiple values.  And if the parameter is part of the selection formula it could slow the report down.  But a string parameter input won’t have commas or decimal points to contend with.

Of course with a string parameter there is nothing to prevent a user from entering the letter O instead of a zero.  So if you use this method I also recommend that you give the parameter an “edit mask” of something like 999000.  This tells CR to accept only numeric characters as inputs for the string parameter.  The zeros are required positions while any positions with nines are optional.









Leave a Reply

Jeff-Net
Recrystallize Pro

Crystal Reports Server