poopiebear
New Member
- Joined
- Nov 19, 2010
- Messages
- 41
I keep getting Run-time error 438 and have no idea why. The premise of this code is to check to see if there are any empty textboxes before a new userform appears with the answer. It works when there is at least one textbox that doesn't have data it to display a message box, but when all the textboxes have data in there, the error pops up. What am I missing?
This coding is in UserForm1 and if all the fields are completed, I want UserForm2 to open.
This is the line that gets highlighted when the error appears:
This coding is in UserForm1 and if all the fields are completed, I want UserForm2 to open.
Code:
'Validates if data is entered in all fields
Private Sub CommandButton1_Click()
Dim cCont As Control
For Each cCont In Me.Controls
If TypeName(cCont) = "TextBox" And cCont.Value = "" And cCont.Visible <> False Then
MsgBox "Please Complete All Fields"
OK = True
GoTo L1
Exit For
End If
Next cCont
'Displays TCB amount in new window
UserForm2.Show
L1:
End Sub
This is the line that gets highlighted when the error appears:
Code:
If TypeName(cCont) = "TextBox" And cCont.Value = "" And cCont.Visible <> False Then