Formatting optional decimals

G

Guest

I would like to format numbers in my report as follows: If the number is an
integer, display the number, if the number is not display 2 decimal places.

I tried "#.##" as the Format Property for the control but that shows the "."
for integers.

I tried an IIF as control source but that produced an error. {
IIF(INT([num]) = [num],format([num],"#"),format([num],"#.##")) }

Any help would be appreciated...
 
M

Marshall Barton

R said:
I would like to format numbers in my report as follows: If the number is an
integer, display the number, if the number is not display 2 decimal places.

I tried "#.##" as the Format Property for the control but that shows the "."
for integers.

I tried an IIF as control source but that produced an error. {
IIF(INT([num]) = [num],format([num],"#"),format([num],"#.##")) }


I think the error is caused by the name of the text box with
the expression. Try changing it to something else such as
txtNum
 
O

onedaywhen

R said:
I tried an IIF as control source but that produced an error. {
IIF(INT([num]) = [num],format([num],"#"),format([num],"#.##")) }

Try something like

FORMAT([num], IIF(INT([num]) = [num], "#", "#.##")

Jamie.

--
 
O

onedaywhen

onedaywhen said:
Try something like

FORMAT([num], IIF(INT([num]) = [num], "#", "#.##")

Missed a closing paren:

Format([num], IIF(INT([num]) = [num], "#", "#.##"))

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top