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

returning a Zero if no data is entered 1

Status
Not open for further replies.

Wrecker

Technical User
Aug 29, 2001
126
0
0
US
Using a form for data entry, how do I make Access return a "0" if the user leaves the Textbox blank in a form? Would the expression be written as an if statment in an event procedure for the text box?

Thanks in Advance
Wrecker
 
Wrecker,
Yes....but there are a number of ambiguities associated with your question. Is the Textbox bound or unbound? If it is unbound, then of course you will handle all data-validation before you access your db, this would be a great example of a "Class", ie you create a Class to handle your interface with your db. If you are using Bound Controls, then you should probably put your data validation code in the binding object's (DataControl) validatedata event; however, as long as the data is validated before it is saved then we are only really argueing symantics.

Hunter
 
You can achieve what you would like to do in several ways, depends when you would like the 0 to be filled into the empty text boxes.

The easiest way is ceirtanly the use of the default value. Simply enter a 0 into the default value property and if no data enter, zero will be the value entered into the table.

If you would like the zero to appear when the user enters the data into the form it gets a little bit more complicated.

Use the after_update event:
If me.control=null then
me.control=0
End if

Control represents the name of your control on the form.

ElGuapo


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top