Discussion Locked

Toolbars In Access

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I'm using Access 2000. I'm trying to use Customized toolbar. I had made menu bar by the name of MenuBar. I want to use the refernce of that toolbar in my VBA code. HOw?

1 reply

by slator.turner

Below is some code that should give you what you want. CAUTION: This is only part of the code due to space limitations, so use for reference only.
SEE: "CommandBars" @ Answer Wizard in VBA Help
SEE: Q209974 @ Microsoft KnowledgeBase
url= http://support.microsoft.com
/default.aspx?scid=kb;en-us;209974
'exists, remove, then add back a blank menu
Dim cbmCommandBarMenu As CommandBar
Dim cbmAddMenuDropdown As CommandBarPopup
Dim intLong As Long
'used to determine integer value of constants,
'esp, msoButonStyle
On Error Resume Next
Application.CommandBars("mbrDEQMain").Controls_
("Reports").Delete
Set cbmCommandBarMenu = Application.CommandBars_
("mbrDEQMain")
With cbmCommandBarMenu.Controls
Set cbmAddMenuDropdown = .Add _
(Type:=msoControlPopup,_
Before:=15)
With cbmAddMenuDropdown
.Caption = "Reports"
.BeginGroup = True
End With
End With
'Add the menu items
Dim strCommandBarCaption As String
Dim strCommandBarOnAction As String
Dim strCommandBarTag As String
Dim strCommandBarToolTip As String
Dim intCommandBarStyle As Long
'0=msoButtonAutomatic;
'1=msoButtonIcon; 2=msoButtonCaption;
'3=msoButtonIconAndCaption;
Dim intCommandBarFaceID As Integer
Dim bolCommandBarBeginGroup As Boolean
With rstReports
.MoveLast
.MoveFirst
Do While Not .EOF
With cbmAddMenuDropdown.Controls.Add_
(msoControlButton)
.Caption = rstReports_
("ReportsMenu_Name")
.OnAction = "=MenuReport_Automation()"
.Parameter = rstReports("ezx_ObjName")
.TooltipText = "Tool Tip Text"
.Style = msoButtonIconAndCaption
.FaceId = 500
End With
.MoveNext

This discussion is closed to new replies.