Forms runtime error 2110

dkafry

New Member
Joined
Sep 26, 2009
Messages
15
I have a form that has three tabs - a checkbook tab, a budget tab and a balance tab. If I edit the code for the balance tab (the last in the group) and then run the form I get a "runtime error 2110 can't move focus to the control because it is invisible, not enabled or of the type that does not accept the focus." If I go back and edit the form and click on the checkbook tab (the first tab in the group) and then exit the debugger and run the form it works fine. What can I change in order for this to work regardless of which tab I have active when I leave the vba debug?
The code is:
Sub CheckBookForm()
Application.WindowState = xlMinimized
TestUserForm.Show False
End Sub
It errors on "testuserform.show false"

Thanks for the help!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Goto Tools>Options... and on the General tab select Break On All Errors.

Now when you get the error hit debug and you should be directed to the offending line of code.:)
 
Upvote 0
This is already set and the highlighted part of the code that errored is:

TestUserForm.Show False

Thanks for the reply!
 
Upvote 0
Well I don't quite understand that.

Normally when you get such an error and the Show code is highlighted it means the problem lies in whatever code is triggered when you show the form.

And normally by setting the option I suggested the Debugger will take you to the problem code.

The only other thing I can think of is why are you using False?

Do you actually want to show the userform as modeless?
 
Upvote 0
I tried it as "true" but with no luck. I don't remember why I used "false." At the time it seemed the thing to do. (I'm new at this.) Again, I can get around the error by going back into debug and click on the checkbook tab (the first tab) and then the macro runs fine. More than anything, it's a curious thing that I'd like to get an answer for - but the macro does work. What is a modeless form and how would I make it otherwise?
 
Upvote 0
Don't use True or False.

You would normally only use a modeless form if you wanted to display a form and also still be able to work with the workbook/sheet.

I don't quite know how to describe it technically but it just sort of means that the form doesn't have exclusive focus.

As for the error, it's hard to tell what the problem is without more information eg code etc.
 
Upvote 0
That prompts my memory - I think I set it to modeless because the form automatically opens when I open the spreadsheet - without modeless, if the form errored, I wouldn't be able to get into my spreadsheet.

The below is all there is to the code:

Sub CheckBookForm()
Application.WindowState = xlMinimized
TestUserForm.Show False
End Sub
 
Upvote 0
So there's no code in the userform module?:)
 
Upvote 0
Change your offending line to

TestUserForm.Show vbModeless

From VBA Help
Constant Value Decription
vbModeless 0 UserForm is modeless.
vbModal 1 UserForm is modal (default).
 
Upvote 0
Application.WindowState = xlMinimized << Looks Stranger?? Seems like this is minimizing the Window before Showing the Forms -- Seems like a contradiction
Comment out the line Application.WindowState = xlMinimized and run code again.
 
Upvote 0

Forum statistics

Threads
1,213,501
Messages
6,114,010
Members
448,543
Latest member
MartinLarkin

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