views:

183

answers:

1

Lets say I have two text boxes on a form. the first returns a count value from a SQL statement, or a domain aggregate expression, etc. the second does the same with additional parameters.

Now i want to have another text box (#3) that divides one by the other for a very simple percentage. like this for a controlsource:

=[textbox2]/[textbox1]

this works great unless the original counted value returned is a zero. If the first returned value is a zero, then the second is going to be a zero too, and ideally 0 / 0 should come out to zero, but I get a #Num! error string in the text box.

I realize this is yet another weird request but this is for a dashboard form that has about 50 of these, and they work great, unless I hit a zero.

So is there any way I can set text box properties that i may be unaware of, for this to work without having to write numerous If statements in the code?

Thanks!

+1  A: 

I cannot see how you can avoid an if statement when divide by zero is a possibility

=IIf(TextBox1<>0, TextBox2/TextBox1,"N/A")
Remou
So I can use this as the control source instead of just =[1]/[2] and get the achieved results. Sorry I meant If statements in the VB like If me.text1 = 0 then.... this is better!
Justin
AWESOME!! Remou you have helped me out once again! And as always I appreciate it very much!
Justin