How to set all forms to the same custom menu using code 
Author Message
 How to set all forms to the same custom menu using code

Hi,

I have a db with approx 50 forms in it.  I have made a custom menu bar,
which I want to apply to all the forms, but don't really want to have to
open each one in design mode and set the menu etc..

I know there is probably a way to set the menu bar property programatically
for all forms - has anyone got an example?

Cheers

Paul



Sat, 29 Nov 2003 19:41:38 GMT  
 How to set all forms to the same custom menu using code
Paul,

Here's a quick example

Public Sub SetAllForms()
'This code will set a property on all forms (such as a help file)

    Dim obj As AccessObject, dbs As Object
    Dim formLoop As Form

    ' Loop through all the forms
    For Each obj In CurrentProject.AllForms

            'Open the form in design mode (to avoid events)
            DoCmd.OpenForm obj.Name, acDesign

                'Modify the property of the form
                For Each formLoop In Forms
                    formLoop.HelpFile = "SM2K.hlp"
                Next formLoop

            'Close and save the form
            DoCmd.Close acForm, obj.Name, acSaveYes

    Next obj

MsgBox "Done"

End Sub

Quote:
-----Original Message-----

Hi,

I have a db with approx 50 forms in it.  I have made a custom menu bar,
which I want to apply to all the forms, but don't really want to have to
open each one in design mode and set the menu etc..

I know there is probably a way to set the menu bar property programatically
for all forms - has anyone got an example?

Cheers

Paul

.



Sat, 29 Nov 2003 21:14:51 GMT  
 How to set all forms to the same custom menu using code
Thanks Don - works brillaintly.  A useful piece of code which I shall use
for all sorts of object property setting in the future!


Paul,

Here's a quick example

Public Sub SetAllForms()
'This code will set a property on all forms (such as a help file)

    Dim obj As AccessObject, dbs As Object
    Dim formLoop As Form

    ' Loop through all the forms
    For Each obj In CurrentProject.AllForms

            'Open the form in design mode (to avoid events)
            DoCmd.OpenForm obj.Name, acDesign

                'Modify the property of the form
                For Each formLoop In Forms
                    formLoop.HelpFile = "SM2K.hlp"
                Next formLoop

            'Close and save the form
            DoCmd.Close acForm, obj.Name, acSaveYes

    Next obj

MsgBox "Done"

End Sub

Quote:
-----Original Message-----

Hi,

I have a db with approx 50 forms in it.  I have made a custom menu bar,
which I want to apply to all the forms, but don't really want to have to
open each one in design mode and set the menu etc..

I know there is probably a way to set the menu bar property programatically
for all forms - has anyone got an example?

Cheers

Paul

.



Mon, 01 Dec 2003 21:45:29 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Create custom control in form using code (code wizard adding ocx to form)

2. Windows forms designer automatically adds code that sets properties of custom controls

3. Adding menu items to custom forms using Outlook 98

4. Setting values to Custom Fields on Custom Forms

5. Need Help: Trouble adding a custom menu pick to a custom popup menu in VBA

6. Synchronizing Two Forms using Code with RecordSource set at runtime

7. Set Defaults for Many fields, Using Form/Code

8. Set Custom menu at startup

9. Setting Shortcut Text in Custom Menu Bar?

10. Custom Menu Button to Set View?

11. custom properties setting and right click menu

12. how to get custom form and send custom form from VB

 

 
Powered by phpBB® Forum Software