How to setfocus in Multipages

fayez_MrExcel

Active Member
Joined
Oct 29, 2005
Messages
439
Office Version
  1. 365
Platform
  1. 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
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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.
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,892
Members
449,058
Latest member
Guy Boot

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
Back
Top