runtime error 2110

ApolloShine

New Member
Joined
Jun 23, 2015
Messages
8
Still new with VBA, using only what i have learned online and on these forums lol.
I have created a multipage userform in excel.

i entered a code to set focus on blank text before moving on to the next page when clicking "next" however i keep getting Run-time error '2110'
"Cant move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus".

i think it may be because it is still moving on to page 2 instead of keeping the blank textbox active.

the code i am using is

Private Sub nextbtn_Click()
With MultiPage1
.Value = (.Value + 1) Mod (.Pages.Count)
End With

If Not IsDate(Me.calldate.Value) Then
MsgBox "The date box must contain date"
Me.calldate.SetFocus
Exit Sub
End If


Thanks for all the help :)
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Your code is setting focus after it changes the multipage.

Try something like this. Change the MultiPage1 value to the page that contains calldate

Code:
[COLOR=darkblue]Private[/COLOR] [COLOR=darkblue]Sub[/COLOR] nextbtn_Click()
    
    [COLOR=darkblue]With[/COLOR] MultiPage1
    
        [COLOR=darkblue]If[/COLOR] .Value = [COLOR=#ff0000]0[/COLOR] [COLOR=darkblue]Then[/COLOR]  [COLOR=green]'Page that contains calldate[/COLOR]
            [COLOR=darkblue]If[/COLOR] [COLOR=darkblue]Not[/COLOR] IsDate(Me.calldate.Value) [COLOR=darkblue]Then[/COLOR]
                MsgBox "The date box must contain date"
                Me.calldate.SetFocus
                [COLOR=darkblue]Exit[/COLOR] [COLOR=darkblue]Sub[/COLOR]
            [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
        
        .Value = (.Value + 1) Mod (.Pages.Count)
        
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
    
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Last edited:
Upvote 0
the post before the edit worked!! could you repost it again please :)

Did you lose it?

Code:
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] nextbtn_Click()
    
    [color=darkblue]If[/color] [color=darkblue]Not[/color] IsDate(Me.calldate.Value) [color=darkblue]Then[/color]
        MsgBox "The date box must contain date"
        Me.calldate.SetFocus
        [color=darkblue]Exit[/color] [color=darkblue]Sub[/color]
    [color=darkblue]End[/color] [color=darkblue]If[/color]
    
    [color=darkblue]With[/color] MultiPage1
        .Value = (.Value + 1) Mod (.Pages.Count)
    [color=darkblue]End[/color] [color=darkblue]With[/color]
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,435
Members
452,326
Latest member
johnshaji

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