dmorgan20
dmorgan20

Reputation: 363

Simple IF statements not working

I am using simple IF statements but they are simply getting ignored when the command button is clicked for some reason.

What am I missing?

    If Text4 = "" Then
MsgBox "You must add a GS Reference", vbInformation
Exit Sub
Else
End If

If Text6 = "" Then
MsgBox "You must add a Service Account number", vbInformation
Exit Sub
Else
End If

If Text8 = "" Then
MsgBox "You must pick an advisor", vbInformation
Exit Sub
Else
End If

If Me.Text10 = "" Then
MsgBox "You must select a date received option", vbInformation
Exit Sub
Else
End If

If Me.Text12 = "" Then
MsgBox "You must select a date failed option", vbInformation
Exit Sub
Else
End If

To me these should just be checking if a textbox is blank, if blank display a message the stop running the code. But its not working at all.

Upvotes: 0

Views: 244

Answers (1)

Sergey S.
Sergey S.

Reputation: 6336

Try to replace checking textboxes by commands like this:

If Nz(Text6,"") = "" Then

or

If Len(Nz(Text6,"") = 0 Then

The last one works a little bit faster

Upvotes: 4

Related Questions