business_analyst
Board Regular
- Joined
- Jun 5, 2009
- Messages
- 99
Ok, so I have the following code that checks the textboxes within a Userform and if there is a blank text box, a message box pops up prompting the user to fill them out. The problem is, this code only seems to work in the userform from a top-down approach. In other words, if you don't fill anything in the first textbox, but enter something in the second, it allows the user to continue. Otherwise, it works fine.
Dim proceed As Integer
Private Sub cmd_1_next_Click()
check Me
If proceed = 0 Then
MsgBox ("Please fill out all textboxes")
Else
frm_00.Hide
frm_01.Show
End If
End Sub
Private Sub check(ByVal frmname As Object)
Dim ctl As Control
For Each ctl In frmname.Controls
If TypeName(ctl) = "TextBox" Then
If ctl.Value = "" Then
proceed = 0
Else
proceed = 1
End If
End If
Next ctl
End Sub
Any help would be greatly appreciated, thanks All.
Dim proceed As Integer
Private Sub cmd_1_next_Click()
check Me
If proceed = 0 Then
MsgBox ("Please fill out all textboxes")
Else
frm_00.Hide
frm_01.Show
End If
End Sub
Private Sub check(ByVal frmname As Object)
Dim ctl As Control
For Each ctl In frmname.Controls
If TypeName(ctl) = "TextBox" Then
If ctl.Value = "" Then
proceed = 0
Else
proceed = 1
End If
End If
Next ctl
End Sub
Any help would be greatly appreciated, thanks All.