Default to the Default Value

dsellers1

Registered User.
Local time
Yesterday, 16:32
Joined
May 19, 2009
Messages
39
I have an unbound text box that calculates a range of other text boxes. The unfortunate part is that if one of these text boxes are blank, the calculation doesn't work (correct me if I'm wrong). To get around this, I have defaulted each text box with a 0 and set the conditional format for this value to white so that the form looks better. I am concerned about someone deleting the 0 without knowing it, thus not populating the total. To get around this, I was trying to write code to say if a text box is blank, then populate a 0. To me, this should be pretty easy to write but I can't seem to get it to work. My code is simply:

If Me.Text32 = "" Then
Me.Text32 = "0"
End If

I have tried to add this to AfterUpdate, OnChange, and OnLostFocus with no success. Any ideas?
 
In you calculation have you tried using the Nz function?

This will capture if a text box is empty and if it is, you can set the value to 0 so the calculation still works. For example:

Me.txtCalcField = Nz([Me.Text32],0) + Nz([Me.Text33],0) etc.
 

Users who are viewing this thread

Back
Top Bottom