Reputation: 23
I want to give people the option of running an Access 2016 database in one of two ways.
1. Single window, tabbed. This is the default in Access and avoids creating a bunch of separate windows. This is achieved by leaving the property "PopUp" on forms set to false/no.
2. Multi-window mode, with only the main navigation form staying in the main Access window.
Some people prefer single window tabbed mode, and some people prefer multi-window mode. I thought it was going to be easy to implement this simply by using VBA in "On Form Load" but when I try Me.PopUp = True
, I get an error.
Run-time error '2136':
To set this property, open the form or report in Design view.
Is there any way I can get around this limitation to modify Me.PopUp
with VBA, or some other properties that I can change with VBA that will cause a form to pop up as a new tab or a new window based on a global variable being set to true or false?
Upvotes: 0
Views: 1876
Reputation: 21379
With database set for Tabbed Documents, open form or report in popup mode by using acDialog parameter in WindowMode argument of OpenForm.
If you want to use a global variable as a test for whether or not to use popup, declare variable in a general module, set it when main form opens, then use it in IIf().
Docmd.OpenForm "MyForm", , , , , IIf(gblMode = "Pop", acDialog, "")
Beware, global variables lose value if any code breaks on run-time error. Alternatives are TempVars or set a textbox on form that never closes.
Upvotes: 1