How to setfocus in Multipages

fayez_MrExcel

Active Member
Joined
Oct 29, 2005
Messages
394
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
 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

completelystoked

New Member
Joined
Jul 16, 2007
Messages
21
Each sheet on a multipage is assigned a value try this

Code:
Multipage.value = 0        ‘for the first page
Multipage.value = 1        ‘for the second... etc

This should change the page... then you could move on to the

Code:
Combobox.setfocus       ‘to set the focus to the combobox

Let me know how it goes.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,385
Messages
5,601,331
Members
414,446
Latest member
CRAVIN

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top