Suppress Trailing Decimal

G

Guest

Question: How to do I format a report to to suppress the trailing zero and
decimal point for numbers greater than 1 (eg, 22 not 22.) and to display
leading zero for
numbers less than 1 (eg, 0.1) in the same text box? Access 97

Report contains text box named [calculated number], whose values ranges from
X.X to XX (positive numbers).
[calculated number] = [number]*0.1/2.
[number] is supplied by the end-user via a form.
[number]'s format = fixed with decimal place = auto.

I currently have the [calculated number]'s format = 0.# which works fine for
numbers less than one but not for numbers greater than one (displays 22.
instead of 22). I have searched the Help Topic for MS Access 97 and also
have searched office online and am unable to figure out a solution thus far.

What is the best approach to my question? Any direction is much appreciated.
 
K

Ken Snell [MVP]

A bit kludgy, but:

[calculated number] = IIf(([number]*0.1/2)<1, Format([number]*0.1/2,"0",
Format([number]*0.1/2, "0.0")
 
G

Guest

hmmm....works almost all time but not quite. =(

Number is significant to one decimal.

< THAN 1
0.5 --> should display 0.5

=> THAN 1
1.0 --> should display 1
1.5 --> should display 1.5
11.0 --> should display 11
11.1 --> should display 11.1

Side bar: I'm in the healthcare industry. So for patient safety reasons, it
is "best practice" to display leading zeros (no: .05, yes: 0.5, yes: 0.005)
and suppress trailing zeros (no: 50.00000, no: 50.0, yes: 50).

Any other thoughts?? =)

Thanks Ken.


Ken Snell said:
A bit kludgy, but:

[calculated number] = IIf(([number]*0.1/2)<1, Format([number]*0.1/2,"0",
Format([number]*0.1/2, "0.0")

--

Ken Snell
<MS ACCESS MVP>

Diana said:
Question: How to do I format a report to to suppress the trailing zero and
decimal point for numbers greater than 1 (eg, 22 not 22.) and to display
leading zero for
numbers less than 1 (eg, 0.1) in the same text box? Access 97

Report contains text box named [calculated number], whose values ranges
from
X.X to XX (positive numbers).
[calculated number] = [number]*0.1/2.
[number] is supplied by the end-user via a form.
[number]'s format = fixed with decimal place = auto.

I currently have the [calculated number]'s format = 0.# which works fine
for
numbers less than one but not for numbers greater than one (displays 22.
instead of 22). I have searched the Help Topic for MS Access 97 and also
have searched office online and am unable to figure out a solution thus
far.

What is the best approach to my question? Any direction is much
appreciated.
 
K

Ken Snell [MVP]

Ahhh...you've changed what you requested. Your original post did not say
that you wanted a decimal place for numbers greater than or equal to 1.

[calculated number] =
IIf(Right(Format(Round([number]*0.1/2,1),"0.0"),1)="0",Format([number]*0.1/2,"0"),
Format([number]*0.1/2, "0.0"))


--

Ken Snell
<MS ACCESS MVP>


Diana said:
hmmm....works almost all time but not quite. =(

Number is significant to one decimal.

< THAN 1
0.5 --> should display 0.5

=> THAN 1
1.0 --> should display 1
1.5 --> should display 1.5
11.0 --> should display 11
11.1 --> should display 11.1

Side bar: I'm in the healthcare industry. So for patient safety reasons,
it
is "best practice" to display leading zeros (no: .05, yes: 0.5, yes:
0.005)
and suppress trailing zeros (no: 50.00000, no: 50.0, yes: 50).

Any other thoughts?? =)

Thanks Ken.


Ken Snell said:
A bit kludgy, but:

[calculated number] = IIf(([number]*0.1/2)<1, Format([number]*0.1/2,"0",
Format([number]*0.1/2, "0.0")

--

Ken Snell
<MS ACCESS MVP>

Diana said:
Question: How to do I format a report to to suppress the trailing zero
and
decimal point for numbers greater than 1 (eg, 22 not 22.) and to
display
leading zero for
numbers less than 1 (eg, 0.1) in the same text box? Access 97

Report contains text box named [calculated number], whose values ranges
from
X.X to XX (positive numbers).
[calculated number] = [number]*0.1/2.
[number] is supplied by the end-user via a form.
[number]'s format = fixed with decimal place = auto.

I currently have the [calculated number]'s format = 0.# which works
fine
for
numbers less than one but not for numbers greater than one (displays
22.
instead of 22). I have searched the Help Topic for MS Access 97 and
also
have searched office online and am unable to figure out a solution thus
far.

What is the best approach to my question? Any direction is much
appreciated.
 
K

Ken Snell [MVP]

Or

[calculated number] =
IIf(Right(Format([number]*0.1/2,"0.0"),1)="0",Format([number]*0.1/2,"0"),
Format([number]*0.1/2, "0.0"))

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
Ahhh...you've changed what you requested. Your original post did not say
that you wanted a decimal place for numbers greater than or equal to 1.

[calculated number] =
IIf(Right(Format(Round([number]*0.1/2,1),"0.0"),1)="0",Format([number]*0.1/2,"0"),
Format([number]*0.1/2, "0.0"))


--

Ken Snell
<MS ACCESS MVP>


Diana said:
hmmm....works almost all time but not quite. =(

Number is significant to one decimal.

< THAN 1
0.5 --> should display 0.5

=> THAN 1
1.0 --> should display 1
1.5 --> should display 1.5
11.0 --> should display 11
11.1 --> should display 11.1

Side bar: I'm in the healthcare industry. So for patient safety reasons,
it
is "best practice" to display leading zeros (no: .05, yes: 0.5, yes:
0.005)
and suppress trailing zeros (no: 50.00000, no: 50.0, yes: 50).

Any other thoughts?? =)

Thanks Ken.


Ken Snell said:
A bit kludgy, but:

[calculated number] = IIf(([number]*0.1/2)<1, Format([number]*0.1/2,"0",
Format([number]*0.1/2, "0.0")

--

Ken Snell
<MS ACCESS MVP>

Question: How to do I format a report to to suppress the trailing zero
and
decimal point for numbers greater than 1 (eg, 22 not 22.) and to
display
leading zero for
numbers less than 1 (eg, 0.1) in the same text box? Access 97

Report contains text box named [calculated number], whose values
ranges
from
X.X to XX (positive numbers).
[calculated number] = [number]*0.1/2.
[number] is supplied by the end-user via a form.
[number]'s format = fixed with decimal place = auto.

I currently have the [calculated number]'s format = 0.# which works
fine
for
numbers less than one but not for numbers greater than one (displays
22.
instead of 22). I have searched the Help Topic for MS Access 97 and
also
have searched office online and am unable to figure out a solution
thus
far.

What is the best approach to my question? Any direction is much
appreciated.
 

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