calculation of report

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
 
R

Rick Brandt

_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.
 
B

_Bigred

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.
 
B

_Bigred

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.
 
Y

yaohong.chng

Use the NZ( ) function. Hope it helps. Since if a player doesn't have
any at bats, it's a null value.
 
K

kre

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.
 
R

Rick Brandt

_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])
 
D

Duane Hookom

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])
 

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

Similar Threads


Top