Creating a custom command bar with check mark options

O

Ozmael

Hi Experts,

I'm using Access 2003. I'm trying to create a command bar which has sub menu
with check mark options (similar to the Window menu in Access where a check
mark and highlighted in an orange box denotes the current or selected window).

For example the menu should look like this:

Apply Filter
Clear Filter
Projects ---(sub menu)--> x Active Only
Inactive Only
Active & Inactive

(where 'x' denotes the checked or selected option amoung the 3
choices)

I've successfully created the menu and called it "Propel: Main Filter
Shortcut". I created the menu using Access, Tools, Customise. I don't create
it at runtime with VBA.

I've also successfully attached it to my form by setting the Shortcut Menu
Bar property. The menu successfully pops up when I right click on the form.

Where I'm getting stuck......

I'm trying to reference the sub menu items (Active, Inactive, Active &
Inactive) of the "Projects" menu item. Then depending on which one is chosen,
mark that denote that choice with a check mark in front of it.

I'm assuming (but not sure) that the State property of CommandBarButton
controls the check mark where msoButtonDown denotes the selected option??????

I've tried this code but can't get it to work. Access compains that the
"Method or data member not found." Obviously I'm not referencing the sub menu
properly.

Dim cb As CommandBar
Dim cbb As CommandBarButton, cbb2 As CommandBarButton
Set cb = CommandBars("Propel: Main Filter Shortcut")
Set cbb = cb.Controls("Projects")

Select Case intProjects

Case 1 'Active projects only

Set cbb2 = cbb.Controls("Active Only")

cbb.State = msoButtonDown

Case 2 'Inactive projects only

Set cbb2 = cbb.Controls("Inactive Only")
cbb.State = msoButtonDown

Case 3 'Active and inactive projects

Set cbb2 = cbb.Controls("Active & Inactive")
cbb.State = msoButtonDown

End Select
 
Top