Full Version: required field, unbound form
UtterAccess Forums > MicrosoftŪ Access > Access Forms
I've created an unbound form with text boxes and a "save" command.
I'm having a problem making sure a blank text box is not saved to a table after the "Save" cmd is clicked.
I've used the Data Properties on the unbound text box and I've inserted code in the Save command. Both unsuccesful.
It seems that if no data is entered in the text box, the criteria are not applied.
At this point, I just need to make sure the text box is not null.
How can I assure that a blank text box is not saved to a table whether or not data is entered or edited in the text box?
You can use the "If .....Then ....Else " function.
If isnull(yourtextboxname) then msgbox"Your must enter data in the text box ",vbcritical
Larry Larsen
Some thing like:

'Check txtSearch for Null value or Nill Entry first.
nbsp;   If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
        MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
    Exit Sub
End If

Exit Sub.. should take you out of the save routine..
On your Save button, try something like this:
f(Eval("Forms!FormName!ControlThatSHouldNotBeNull Is Null")) then
MsgBox "You must enter data into the null field in order to continue."
Exit Sub
You can repeat this part for each field you want to validate. Check all of your fields before you run any additional code you may have.
My attempts had the wrong syntax. I was trying:
If textbox = null ......
Thanks for the IsNull direction.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.