Calculating Percentages

  • Thread starter Thread starter SB via AccessMonster.com
  • Start date Start date
S

SB via AccessMonster.com

Hi

Please can you help with the following, the query works fine when there are
actual values but when the number is 0 it returns an error please see below:

A B C
%
50 5 10
40 4 10
0 0 #Error

The calculation is the following /[A]*100. Ideally would like the result
were #Error is equals 0.

Any help will be appreciated.

Many Thanks
 
Dear SB:

And I know better than that.

IIf(B = 0, 0, A / IIf(B = 0, 1, B))

Tom Ellison
 
Dear Tom,

Actually, in a query the following works fine. In a VBA module it errors,
but in a query (with Jet) it works.

IIf(A=0,0,B/A * 100)


Tom Ellison said:
Dear SB:

And I know better than that.

IIf(B = 0, 0, A / IIf(B = 0, 1, B))

Tom Ellison


SB via AccessMonster.com said:
Hi

Please can you help with the following, the query works fine when there
are
actual values but when the number is 0 it returns an error please see
below:

A B C
%
50 5 10
40 4 10
0 0 #Error

The calculation is the following /[A]*100. Ideally would like the
result
were #Error is equals 0.

Any help will be appreciated.

Many Thanks

 
Dear John:

Yes, your right! I confused myself. I wrote and tested this in VBA after
giving the first answer. Doesn't hurt, though!

Tom Ellison


John Spencer said:
Dear Tom,

Actually, in a query the following works fine. In a VBA module it errors,
but in a query (with Jet) it works.

IIf(A=0,0,B/A * 100)


Tom Ellison said:
Dear SB:

And I know better than that.

IIf(B = 0, 0, A / IIf(B = 0, 1, B))

Tom Ellison


SB via AccessMonster.com said:
Hi

Please can you help with the following, the query works fine when there
are
actual values but when the number is 0 it returns an error please see
below:

A B C
%
50 5 10
40 4 10
0 0 #Error

The calculation is the following /[A]*100. Ideally would like the
result
were #Error is equals 0.

Any help will be appreciated.

Many Thanks


 
Back
Top