VBA to setup forms properties

aspfun

Registered User.
Local time
Today, 00:39
Joined
Apr 22, 2006
Messages
29
There are 20 forms in my app mdb file.
I need to set form property for each form in design view, such as popup=no, autocenter=yes.
How to use vba to do it?
 
Both the PopUp and AutoCenter properties need to be set whilst the form is in design view. So unless you need to do this dynamically it probably easiest to set these properties whilst you are building the forms. However if you do need to do it dynamically the code using code along the lines of;
Code:
DoCmd.OpenForm "YourFormName", acDesign     [COLOR="DarkGreen"]'Open Form in design view[/COLOR]

[COLOR="DarkGreen"]'You will need an [B]If Then[/B] test to determine how to set the properties[/COLOR]

        Forms!YourFormName.PopUp = False     [COLOR="DarkGreen"]'Set Property False = No, True = Yes[/COLOR]
        Forms!YourFormName.AutoCenter = True     [COLOR="DarkGreen"]'Set Property False = No, True = Yes[/COLOR]
        DoCmd.Close acForm, "YourFormName", acSaveYes     [COLOR="DarkGreen"]'Close and save changes to form[/COLOR]
        DoCmd.OpenForm "YourFormName"     [COLOR="DarkGreen"]'Re-Open form with properties changed[/COLOR]

This code could go in the On Click event of a button the form you are using to open your other forms.
 

Users who are viewing this thread

Back
Top Bottom