fayez_MrExcel
Active Member
- Joined
- Oct 29, 2005
- Messages
- 439
- Office Version
- 365
- Platform
- Windows
I have a form with a multipage, im having a runtime error 2110 because the MSFORMS.TextBox or ComboBox that is having a blank value is inside the multipage, how can i set the focus if the control is inside the multiple page. My code is below please help.
Private Sub cmdSave_Click()
Dim oCtl As MSForms.Control
For Each oCtl In Me.Controls
If TypeOf oCtl Is MSForms.TextBox Or TypeOf oCtl Is MSForms.ComboBox Then
If oCtl.Text = "" Then
MsgBox oCtl.Name & " cannot be empty, please enter a value."
oCtl.SetFocus
oCtl.BackColor = &HC0FFFF
Exit Sub
End If
End If
Next
End Sub
Private Sub cmdSave_Click()
Dim oCtl As MSForms.Control
For Each oCtl In Me.Controls
If TypeOf oCtl Is MSForms.TextBox Or TypeOf oCtl Is MSForms.ComboBox Then
If oCtl.Text = "" Then
MsgBox oCtl.Name & " cannot be empty, please enter a value."
oCtl.SetFocus
oCtl.BackColor = &HC0FFFF
Exit Sub
End If
End If
Next
End Sub