Setting modal from code

dsmaj

Registered User.
Local time
Today, 09:00
Joined
Apr 28, 2004
Messages
96
Is there a way I can set the modal and popup properties of a form that is NOT currently opened from code?

I want to do something like Forms!frm_Initiative.modal = True
while frm_Initiative is not currently loaded.

Thanks in advance,
Sam
 
The following sub should do what you want:
Code:
Public Sub SetModal(frm As String)
    DoCmd.OpenForm frm, acDesign
    Forms(frm).Modal = True
    Forms(frm).PopUp = True
    DoCmd.Close acForm, frm, acSaveYes
End Sub

Call the code with:
Call SetModal("frm_Initiative")


See if this works for you.
 
Yeah....

Yeah, tried using that method already...I guess my questions should really specify that I'm looking to do this WITHOUT actually having to open the form in order to access its properties. Since I've got about 20 forms, and all of their modal properties need to be set/unset at the same time in my code, you can actually see them flickering past, which is no good. Thanks for the reply though....any other ideas?

Sam
 
No, these form properties can not be set without opening the form in design mode.
 
dsmaj said:
you can actually see them flickering past, which is no good.
You can hide the form [screen] updates by turning the Echo off. Check the help files for the Echo option in VBA. Ensure that you turn the Echo back on at the end of the code and also in your error routine for the db could be put in a state that you can not open it if it crashes with the Echo turned off.
 

Users who are viewing this thread

Back
Top Bottom