Problems with capturing Custom Popup Menus Click Events for CommandbarButton in Forms

S

shane Parkinson

I have a project that consists of about 10 customised popup menus that are
connected to 10 different forms. These forms are utilised as sub forms in a
main form consisting of a tab control and the subforms located on different
tabs. The buttons on the customised shortcut menus consist of both standard
access functionality and 4 "Custom" buttons created via the Toolbar
Customisation->Commands Tab->File category->Commands->Custom.

Buttons on the popup menus have been set to private commandbuttonbar
variables defined withevents in the forms. In the Form_load event these
private variables are set to buttons on the each of the forms popup menus,
(see code segment below) The shortcuts menus are composed of built in
buttons and 4 custom buttons dragged to the menus from the toolbar
customisation window i.e. they are not predefined buttons with existing
functionality.

Two problems have become apparent:

Problem 1: The popup menus are appearing and working on each individual
subform in standalone mode i.e open by itself (no main form) but when
combined in the main form, I can use a right click to Open another form but
then when I right click on the new form now on top (open in dialog mode) the
shortcut menu appears but no right click events appear to fire. I.e. it does
not execute the shortcut buttons click event procedure.

Problem 2: When the events do fire, there appears to be a cascading of these
events through the forms. The forms correct click_event is executed but then
a subsequent subforms event also fires and gets executed.

There are 10 subforms with the same approach and shortcut menus defined
where some of the commandbarbuttons are custom buttons and not

I originally had the same private variable names declared in each form
defined withevents, but when all the subforms and main form are combined I
get the behaviours described above so changed them to individual names, but
his hasn't fixed the behaviour.

Anybody got a brain wave on why I'm experiencing these problems?

The code below appears in 10 form modules, but the variable names for the
CommandBarButton's have been defined with different names as well as all the
same name as the actual text on the menu is different.

FORM1:

Private m_cmdBar As Office.CommandBar
Private WithEvents cbbViewEditIssue As Office.CommandBarButton

FORM_LOAD:

Set m_cmdBar = CommandBars(MENU_POPUP_ISSUE)
Set cbbViewEditIssue = m_cmdBar.Controls("View/Edit Issue")

EVENT_PROCEDURE:

Private Sub cbbNewRecord_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)

modInterface.DisplayRecordForm Me, acFormAdd
CancelDefault = True

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