Command Bar with menu and button in Access

micsak

Registered User.
Local time
Today, 17:23
Joined
Mar 27, 2003
Messages
31
I want to create my command Bar with my menus and my buttons in Ms Access.
Can you help me?

Regards
Michael
 
< Question: I want a db.... how do i create it? >

Hmz,

Ok i will bite.... View => Toolbars => Customize

Regards
 
Private Sub cmdCreateFullBar_Click()
Dim MyButton As CommandBarButton
Dim MyBar As CommandBar
Dim cbmCommandBarMenu As CommandBar
Dim cbmMenu1 As CommandBarPopup
Dim cbmMenu2 As CommandBarPopup

Dim cbmCommandBarMenuCascade As CommandBarPopup




Application.CommandBars("OfficeMenubar").Delete
Set MyBar = Application.CommandBars.Add("OfficeMenubar", msoBarTop, True)

With Application.CommandBars("OfficeMenubar")
Set MyButton = .Controls.Add
.Visible = True
.Position = msoBarTop
End With


With MyBar.Controls
Set cbmMenu1 = _
.Add(Type:=msoControlPopup, Before:=1)
' Set caption for new menu.
With cbmMenu1
.Caption = "Menu1 Caption"
' Add single menu item and set properties.
With .Controls.Add(msoControlButton)
.OnAction = "DisplayMessage"
.Caption = "Demo &Menu Item"
.Tag = "DemoMenuItem"
End With
End With

End With





With MyBar.Controls
Set cbmMenu2 = _
.Add(Type:=msoControlPopup, Before:=2)
' Set caption for new menu.
With cbmMenu2
.Caption = "Menu2 Caption"
' Add single menu item and set properties.
With .Controls.Add(msoControlButton)
.OnAction = "DisplayMessage"
.Caption = "Menu Item1"
.Tag = "MenuItem1"
End With
With .Controls.Add(msoControlButton)
.OnAction = "DisplayMessage"
.Caption = "Menu Item2"
.Tag = "MenuItem2"
End With
End With

Set cbmCommandBarMenuCascade = _
cbmMenu1.Controls.Add(msoControlPopup)

With cbmCommandBarMenuCascade
.Caption = "Cascade1"
' Add first cascading menu item and set properties.
With .Controls.Add(msoControlButton)
.Caption = "&Button1"
.OnAction = "DisplayMessage"
.Tag = "Button 1"
End With
' Add second cascading menu item and set properties
With .Controls.Add(msoControlButton)
.Caption = "Button 2"
.OnAction = "DisplayMessage"
.Tag = "Button 2"
End With
End With

Set cbmCommandBarMenuCascade = _
cbmMenu2.Controls.Add(msoControlPopup)

With cbmCommandBarMenuCascade
.Caption = "Cascade2"
' Add first cascading menu item and set properties.
With .Controls.Add(msoControlButton)
.Caption = "&Button3"
.OnAction = "DisplayMessage"
.Tag = "Button 3"
End With
' Add second cascading menu item and set properties
With .Controls.Add(msoControlButton)
.Caption = "Button 4"
.OnAction = "DisplayMessage"
.Tag = "Button 4"
End With
End With

End With
 
micsak, was a question supposed to be attached that piece of code or were you just posting the code for another reason?
 
I had initially this question and when I found the solution I just posted for reference.

Thanks
Michael
 

Users who are viewing this thread

Back
Top Bottom