Hello,
I’m beginner on Access-VB. I try to create a menu and sub-menu programmatically. I can create a menu but not sub-menu.
Could you help me
Here my code.
------------------------------------------
Sub SubMenuCreation()
Dim MyMenubar As CommandBar
Dim NewMenu As CommandBarControl
Dim MyNewMenu As CommandBarControl
Dim NewMenuCtrl As CommandBarControl
Set MyMenubar = CommandBars.ActiveMenuBar
Set NewMenu = MyMenubar.Controls.Add(Type:=msoControlPopup, Before:=10, Temporary:=True)
NewMenu.Caption = "Menu"
If Mid$([Forms]![frmLogin]![Acces], 11, 1) = 1 Then
Set NewMenuCtrl = NewMenu.Controls.Add(Type:=msoControlButton, Id:=1)
NewMenuCtrl.Caption = "Menu-1"
NewMenuCtrl.TooltipText = "Acces Menu-1"
NewMenuCtrl.Style = msoButtonCaption
NewMenuCtrl.OnAction = "M-OpenForm-Menu1"
End If
If Mid$([Forms]![frmLogin]![Acces], 12, 1) = 1 Then
NewMenuCtrl.Caption = "Menu-2"
NewMenuCtrl.TooltipText = "Acces Menu-2"
NewMenuCtrl.Style = msoButtonCaption
NewMenuCtrl.OnAction = "M-OpenForm-Menu2"
End If
‘ How create Menu-2.1 below Menu-2
EndSub
------------------------------------------
Thank for all suggestion.

How to create a menu & submenu ?
lucerias
It looks like your trying to use the VB within Access which is in fact something called VB for Applications and very different from VB.NET which is what these forums are about.
If this is correct then you will want to ask the questions within the VBA forum.
http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=74&SiteID=1
Peter McEvoy
If you want to create a submenu, you actually need to create a menu within a menu. Here's an example i created in one of my Excel project:
Set CustomBar = CommandBars.Add(MenuPopUpName, msoBarPopup, False, True)
With CustomBar
With .Controls.Add(Type:=msoControlPopup)
'*** Menu Level 1
.Caption = "Adjust"
With .Controls.Add(Type:=msoControlButton)
'*** Menu Level 2
.Caption = "Cell Value"
'.FaceId = 462
.OnAction = "Adjust_Cell"
End With
With .Controls.Add(Type:=msoControlButton)
'*** Menu Level 2
.Caption = "Sheet Name"
'.FaceId = 462
.OnAction = "Adjust_Sheet"
End With
End With
End With
Set CustomBar = Nothing