Run time error when using VB to change Form.PopUp value

SGT68

Registered User.
Local time
Today, 15:38
Joined
May 6, 2014
Messages
77
On my app I have an Options form with an option group that says 'Docked' or 'Moveable'. This is so my users can control the look of certain forms. The value of the option group is Docked =1, Moveable = 2. This value is then passed to a global variable .
********************************
Private Sub FrameWindowStyle_AfterUpdate()
GBL_windowStyle = FrameWindowStyle.Value
End Sub
********************************


The global variable then sets the Form's pop-up value to true or false depending like this:
**********************
Private Sub Form_Load()

If GBL_windowStyle = 1 Then
Form.PopUp = True
End If
If GBL_windowStyle = 2 Then
Form.PopUp = False
End If

End Sub

***********************

But i get a VB pop error msg that says
Run-time error '2136'
To set this property , open the form or report in Design View


WTF???? :mad:

Help pls!!
 
Where did you define GBL_windowStyle
 
Where did you define GBL_windowStyle

In a module that gets executed upon app start. The module just contains a sub called Init_globals that initializes a whole bunch of them. Init_globals is called from the form-load of the main menu form of the app.
 
I think you have to do it in the forms open form command:-

'DoCmd.OpenForm "frmMain", , here? (or the next one, one...)
 
I think you have to do it in the forms open form command:-

'DoCmd.OpenForm "frmMain", , here? (or the next one, one...)

Yes.. i think by the time the form-load event of the form in question is executed the popup value has been set, so its too late. I will set the value before the call with an external refererance to the form. Thanks for your reply
 
It's a property that can only be set in Design View like the error message says. There's no way around it.
So if you really want to do this, open the form in design view, set the Popup property, save the changes then open the form. If you're going to convert your db to a runtime db this code will fail because design changes are not permitted.
 

Users who are viewing this thread

Back
Top Bottom