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?
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.