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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I make a text box = 0 if it is left blank?

Status
Not open for further replies.

Blitz

Technical User
Jul 7, 2000
171
US
I have a text box that If it is left blank I want it to automatically put a 0 in the box. How can I do this?
 
Or ou could type this code in the lostfocus event.

If textbox.value = "" then
textbox.value = "0"
Else
End if
 
I'm not sure if the question you asked has been answered. Do you want the default value of the box to be zero or do you just want a zero to show up in the box?
 
You could also use the Before Update of the form to check the value of your textbox, if it is null then set the value to 0. This event only fires if the record is dirty, so you can close the form without the event firing if the record has not be created.

HTH :cool:
RDH

Ricky Hicks
rdhicks@mindspring.com

 
Thanks for the help, what I ended up doing was changing the validation to "Is Not Null" that way if it is left blank it gives a message saying a value must be entered.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top