Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am using Access 2002 to create a report. I have the following fields:
Field 1: shows the cost of the item
Field 2: displays the price paid.
Field 3: Displays as a percentage the price paid in relation to the cost of the item.
This all works fine unless the cost of the item is zero and the price paid is zero. When this is the case "#Num!" is displayed.
If the cost is zero and the price paid is greater then zero then "#Div/0!" is shown.
Rather than display these errors I would like it to simply display zero.
Can this be done using an iif statement? If so could someone give me some pointers on how I would need to structure it? I have tried structuring it along the lines of iif([price_paid]/[item_cost] not between 0.01 and 1000,0,[price_paid]/[item_cost])
This doesnt work. I guess I need to say that if the result is not a number then display zero otherwise .....
Can anyone help me out?Thanks
Andrew

If statements are IF something is Then do, this...Else...do something else.
So, your If statement should read similar to (forgive the context, as I don't have VB or Office on this machine), If calculation is zero, then show zero, else, show the percentage.Life is more painless for those who are brainless.

In general you have to detect the cause of the offending error first. If divisor is zero then message else do calculation. Doing the calculation causes the error.

Thanks for the responses. Did what Wizard-fred suggested and it worked! Why didnt I think of that in the first place!

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |