I have just a user form in access 2007 with a text box and a Save command.
MY code:

Private Sub Save_Click()
If School.Value = "" Then
MsgBox ("Text Box is empty")
else
Msgbox(" Not Empty")

End If
End Sub

When the Save is clicked, and the text box is empty, the second statement is executed with message "Not Empty".
Why not first statement is exected first??

Member Avatar for LastMitch

I have just a user form in access 2007 with a text box and a Save command.

What are you trying to save? Are you exporting a doc?

I'm going to go out on a limb here and say that maybe the text box isn't empty. Maybe it just looks empty. It could have blanks in it. Set a breakpoint at the start of the if and look at the value in the debugger.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.