#num!

AN60

Registered User.
Local time
Today, 17:54
Joined
Oct 25, 2003
Messages
283
I have two fields on a form and a third which gives a percentage based on the other 2 fields. In the third field I have;
[field1]/[field2] using percent format.

This works fine when either field 1 or field 2 contain positive numbers. Usually they have zeroes in each field and then Field3 has the dreaded #num!. How can I replace #num! with either a blank field or zero until one or both of Fields 1 & 2 are used?
 
With CodeContextObject


If ( IsNull(.txtOne) Or IsNull(.txtTwo)) Then
Me.MyCont =0
Else
Me.MyCont=(.txtOne/.txtTwo)
End If
End With
 
Thank you Rich
Could you tell me where I should put it?
 
Thank you PH for your reply.
I have tried your suggestion and I can't get it to work. It still shows the #num!.:confused:
 
Try this, if you dont want the error to popup when an incorrect value is entered, comment this line to look like this...

Code:
'MsgBox Err.Description, vbInformation

It's change is on the AfterUpdate of the second field, but you can do it many other ways, hope this helps.

Edit: I only set it to AfterUpdate on the second field cause i am not aware on how you want it to run and if the fields are bound
________
GT-ONE
 
Last edited:

Users who are viewing this thread

Back
Top Bottom