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

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 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.