Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting a textbox to zero

Status
Not open for further replies.

roddy17

Technical User
Jul 27, 2001
49
CA
I'm wondering if there is a method to set a text box to be equal to 0 (zero) if it contains a null value.
The reason being that i want to do some math with the text boxes: textbox 1 + textbox 2 = textbox 3
This calculation won't be performed if there is a null value in either one of the first two textboxes, and a total must always be displayed - even if it is zero.
 
Nz([textbox 1]) + Nz([textbox 2]) = textbox 3 Joe Miller
joe.miller@flotech.net
 
On the LostFocus event of the control add:

If IsNull(Forms!Form6!Text1.Value) Then
Forms!Form6!Text1.Value = 0
End If


Where Form6 is your form name & Text1 is your textbox name.

Hope this helps... J. Jones
jjones@cybrtyme.com
 
My appologies, i should have been more specific.
These text boxes are appearing on a report, and they are getting their information from a query, which may or may not always churn out a number.
I tried to look for a LostFocus in the Event properties section, but there are no Events for textboxes in reports.
 
Do the calc in the query!!! It'll be MUCH MUCH faster to return data. Put this in a column of the query:

Total: Nz([Field1])+Nz([Field2])

Now you'll have a new column named Total that you can place as the control source of a textbox on your form.

HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top