How can I catch the PopUp Menu Click Event

F

Frank van Boven

Hello MS Access experts,

I've searched the web and googled some newsgroups to find out how I can
react at a click on a pop-up menu in MS-Access (2003).
The WithEvent on an object is maybe a solution.
PLEASE give an example.

I was so happy I found out how to use the MS Office Commandbar, but
after 10 hours I desperate need some help.

Note you have to set reference to the MS Office library.

Best regards,
Frank van Boven

On a button click I call setBmsMenu, witch is in a module.
(It was no problem to keep the code in the form, but now it's in a
module)
After click on the button a popup menu appaers and I can browse through
the choices, but on click on a choice I want to do something with it.
For example open a form.
================= Form =====================================
Private Sub btnOpenForm_Click()

Call setBmsMenu

End Sub
================== Module ==================================

Public Sub setBmsMenu()

On Error GoTo Err_setBmsMenu

Dim objCommandBar As Office.CommandBar

Dim objCommandBarButton As Office.CommandBarButton
Dim objCommandBarPopup As Office.CommandBarPopup


'** Remove possible previous popup menu
For Each objCommandBar In Application.CommandBars
If (objCommandBar.Name = "OpenBmsForm") Then
objCommandBar.Delete
Next objCommandBar
Set objCommandBar = Application.CommandBars.Add("OpenBmsForm",
msoBarPopup)

With objCommandBar.Controls

Set objCommandBarPopup = .Add(msoControlPopup)

With objCommandBarPopup
.Caption = "&Chapter1"
Set objCommandBarButton = .Controls.Add(msoControlButton)
With objCommandBarButton
.Caption = "&Paragraph1"
.Style = msoButtonCaption
End With
End With

Set objCommandBarPopup = .Add(msoControlPopup)

With objCommandBarPopup

.Caption = "&Chapter2"

Set objCommandBarButton = .Controls.Add(msoControlButton)
With objCommandBarButton
.Caption = "&Paragraph1"
.Style = msoButtonCaption
End With

Set objCommandBarButton = .Controls.Add(msoControlButton)
With objCommandBarButton
.Caption = "&Paragraph2"
.Style = msoButtonCaption
End With

Set objCommandBarButton = .Controls.Add(msoControlButton)
With objCommandBarButton
.Caption = "&Paragraph3"
.Style = msoButtonCaption
End With

End With
End With

objCommandBar.ShowPopup 400, 200

' To delete this pop-up menu, call:
' Application.CommandBars("OpenBmsForm").Delete

Exit_setBmsMenu:
Exit Sub

Err_setBmsMenu:
Registreer_Error
Resume Exit_setBmsMenu

End Sub

===============================
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top