calculation of report

  • Thread starter Thread starter _Bigred
  • Start date Start date
B

_Bigred

Access 2000

I have a report and I put a unbound text box on it to calculate the batting
average of the player on the record.

=[Batting!H]/[Batting!AB]

I works but it will return for example: 0.123432123, I want it to only give
me 0.123

I tried to open the report in design view and change the properties for the
unbound text box as follows:
General Number
Decimal Places: 3

But this didn't fix my problem,
TIA,
_Bigred
 
_Bigred said:
Access 2000

I have a report and I put a unbound text box on it to calculate the
batting average of the player on the record.

=[Batting!H]/[Batting!AB]

I works but it will return for example: 0.123432123, I want it to
only give me 0.123

I tried to open the report in design view and change the properties
for the unbound text box as follows:
General Number
Decimal Places: 3

But this didn't fix my problem,
TIA,
_Bigred

Try Fixed instead of General Number.
 
well that was an easy fix Rick, worked like a charm.
Thanks,
_Bigred


Rick Brandt said:
_Bigred said:
Access 2000

I have a report and I put a unbound text box on it to calculate the
batting average of the player on the record.

=[Batting!H]/[Batting!AB]

I works but it will return for example: 0.123432123, I want it to
only give me 0.123

I tried to open the report in design view and change the properties
for the unbound text box as follows:
General Number
Decimal Places: 3

But this didn't fix my problem,
TIA,
_Bigred

Try Fixed instead of General Number.
 
Hey Rick,

with my unbound box (see below) it works good. But if the player doesn't
have any at bats (AB) then it gives me #error.
Is there anyway to N/A for the value?

TIA,
_Bigred



Rick Brandt said:
_Bigred said:
Access 2000

I have a report and I put a unbound text box on it to calculate the
batting average of the player on the record.

=[Batting!H]/[Batting!AB]

I works but it will return for example: 0.123432123, I want it to
only give me 0.123

I tried to open the report in design view and change the properties
for the unbound text box as follows:
General Number
Decimal Places: 3

But this didn't fix my problem,
TIA,
_Bigred

Try Fixed instead of General Number.
 
Use the NZ( ) function. Hope it helps. Since if a player doesn't have
any at bats, it's a null value.
 
Well, it's because without any AB value, it is treated as a null. You
could use something like:
If IsNull([Batting!AB],"N/A",[Batting!H]/[Batting!AB]) or just use
[Batting!H]/NZ([Batting!AB]).

I hope that works.
 
_Bigred said:
Hey Rick,

with my unbound box (see below) it works good. But if the player doesn't have
any at bats (AB) then it gives me #error.
Is there anyway to N/A for the value?

In that case is [AB] null or zero? You can use Immediate-If IIf() to avoid
divide by zero errors.

=IIf(Nz([Batting!AB],0) = 0, "N/A", [Batting!H]/[Batting!AB])
 
I would actually use
=IIf(Nz([Batting!AB],0) = 0, Null, [Batting!H]/[Batting!AB])
Then use the format property of the control to display "N/A".

--
Duane Hookom
MS Access MVP


Rick Brandt said:
_Bigred said:
Hey Rick,

with my unbound box (see below) it works good. But if the player doesn't
have any at bats (AB) then it gives me #error.
Is there anyway to N/A for the value?

In that case is [AB] null or zero? You can use Immediate-If IIf() to
avoid divide by zero errors.

=IIf(Nz([Batting!AB],0) = 0, "N/A", [Batting!H]/[Batting!AB])
 
Back
Top