M
Minal Shah
Hi,
I have created a Custom Form Toolbar, Custom Form Menubar, Form
Shortcut bar and a Form Control Shortcut Bar.
When I go into the individual forms into properties and set the
toolbar, menubar and shortcut bar options it works.
So since I wanted to do this for a large # of forms I wrote this code.
But something is not right. Can someone help me figure out what is
wrong.
This is my first attempt with writting codes and I have no training,
background or experience with this sort of thing.
So please bear with me if I make silly mistakes.
I have worked 2 nights to get here. Any help is welcomed
CODE.
Public Sub SetFormToolbar()
Dim objFrm As AccessObject, frm As Form, ctl As Control
' Go through every form in the database
For Each objFrm In CurrentProject.AllForms
' Skip fixing any "plain" examples
If Right(objFrm.Name, 5) <> "plain" Then
DoCmd.OpenForm FormName:=objFrm.Name, View:=acDesign, _
WindowMode:=acHidden
' Set a pointer to the form just opened
Set frm = Forms(objFrm.Name)
' Set custom menu and toolbars for the form object
' .. only for primary forms
If Left(frm.Name, 3) = "frm" Then
' Clear any saved filter while we're at it
Forms(frm.Name).Filter = ""
' Set the custom menu bar
Forms(frm.Name).MenuBar = "Custom Form Menu Bar"
' Set the custom toolbar
Forms(frm.Name).Toolbar = "Custom Form Toolbar"
' Set the custom shortcut menu bar
Forms(frm.Name).ShortcutMenuBar = "Form Shortcut Bar"
End If
' Loop through all controls
For Each ctl In frm.Controls
' Skip control types that don't have a ShortcutMenuBar property
If (ctl.ControlType <> acCustomControl) And _
(ctl.ControlType <> acSubform) And _
(ctl.ControlType <> acRectangle) And _
(ctl.ControlType <> acLabel) And _
(ctl.ControlType <> acLine) And _
(ctl.ControlType <> acPageBreak) Then
' Set the custom control shortcut menu
ctl.ShortcutMenuBar = "Form Control Shortcut Bar"
End If
' Close the form
DoCmd.Close acForm, objFrm.Name
' Loop to the next form
' Clean up
Set ctl = Nothing
Set frm = Nothing
Set objFrm = Nothing
End Sub
Thanks
Minal
I have created a Custom Form Toolbar, Custom Form Menubar, Form
Shortcut bar and a Form Control Shortcut Bar.
When I go into the individual forms into properties and set the
toolbar, menubar and shortcut bar options it works.
So since I wanted to do this for a large # of forms I wrote this code.
But something is not right. Can someone help me figure out what is
wrong.
This is my first attempt with writting codes and I have no training,
background or experience with this sort of thing.
So please bear with me if I make silly mistakes.
I have worked 2 nights to get here. Any help is welcomed
CODE.
Public Sub SetFormToolbar()
Dim objFrm As AccessObject, frm As Form, ctl As Control
' Go through every form in the database
For Each objFrm In CurrentProject.AllForms
' Skip fixing any "plain" examples
If Right(objFrm.Name, 5) <> "plain" Then
DoCmd.OpenForm FormName:=objFrm.Name, View:=acDesign, _
WindowMode:=acHidden
' Set a pointer to the form just opened
Set frm = Forms(objFrm.Name)
' Set custom menu and toolbars for the form object
' .. only for primary forms
If Left(frm.Name, 3) = "frm" Then
' Clear any saved filter while we're at it
Forms(frm.Name).Filter = ""
' Set the custom menu bar
Forms(frm.Name).MenuBar = "Custom Form Menu Bar"
' Set the custom toolbar
Forms(frm.Name).Toolbar = "Custom Form Toolbar"
' Set the custom shortcut menu bar
Forms(frm.Name).ShortcutMenuBar = "Form Shortcut Bar"
End If
' Loop through all controls
For Each ctl In frm.Controls
' Skip control types that don't have a ShortcutMenuBar property
If (ctl.ControlType <> acCustomControl) And _
(ctl.ControlType <> acSubform) And _
(ctl.ControlType <> acRectangle) And _
(ctl.ControlType <> acLabel) And _
(ctl.ControlType <> acLine) And _
(ctl.ControlType <> acPageBreak) Then
' Set the custom control shortcut menu
ctl.ShortcutMenuBar = "Form Control Shortcut Bar"
End If
' Close the form
DoCmd.Close acForm, objFrm.Name
' Loop to the next form
' Clean up
Set ctl = Nothing
Set frm = Nothing
Set objFrm = Nothing
End Sub
Thanks
Minal