Move or Remove focus from open form

MsAccessNL

Member
Local time
Today, 21:30
Joined
Aug 27, 2022
Messages
204
When I run these two commands: "DoCmd.RunCommand acCmdLayoutView, DoCmd.RunCommand acCmdFormView" from a cmdButton on the mainform it will work but from a subform it doesn't. When I move the focus to another openform, the docmd works. My question is to remove the focus from the main form (if no other form is open). I was thinking about setting the focus to the Menubar or the applicationwindow? Or maybe another solution to have the DoCmd.RunCommand acCmdLayoutView work from a button on a subform?
 
You can't set focus to a form if it has any controls on it.

The layout option isn't available for a subform as it is simply a control on the main form.
You would have to set focus to a control on the parent form to get to layout mode.

But I have to ask why - surely a form layout shouldn't be being adjusted by the end user unless it's possibly a datasheet view?
 
I still get an error when i set the focus to a control on the main form first.
 
I still get an error when i set the focus to a control on the main form first.
I'm not getting an error at all. However, when I go to Layout View, I can't click on any buttons. If so, what's the use? Just curious...
 
I'm not getting an error at all. However, when I go to Layout View, I can't click on any buttons. If so, what's the use? Just curious...
Strange, what is your code to set the focus to the control on the main form?

Reason: i think i found an easy way to create an Accordeon table/subform view (like on websites) I have to overcome a view small problems like this one.
 
How are trying to set focus on the main form?
 
Why would you ever put a form that the user is using into layout view? users don't get to modify objects!!!!!!!!!!!!!!!! If you want to remove focus from the only open form, where would you want it to go? The question makes no sense.
 
Breathe, meditate and breathe again. I love you to. The reason i want to do these two commands is not the issue, it would take to much time to explain. (And the user must be lighting fast to change the object between these two commands..) But Please, let’s keep the reply’s restricted to possible solutions.
 

Users who are viewing this thread

Back
Top Bottom