-----Original Message-----
Hi Steve,
The CommandbarControl object has an enabled property which you can
toggle. Of course you first need to get a reference to
CommandBarControl object which is the "Export" menu item on your
shortcut menu. The easiest way to do this is to assign a value to
the tag property of the menu item and then use that value with the
FindControl method of the Commandbar.
How do you determine whether an item can be exported? For
simplicity's sake, let's say there is a field that you can include
in the RowSource of the listbox which gives you this information.
Make sure that you've modified the ColumnCount of the listbox so
that the values will be available to you using VBA.
The following will work assuming that the Listbox is a simple
listbox (else AfterUpdate won't work). For this example the Shortcut
menu is named 'Custom1' and the tag of the menuitem I am
enabling/disabling is 'CustomButton1'. The boolean value which tells
me whether to enable or disable the item is in the 3rd column of the
listbox rowsource.
Private Sub List16_AfterUpdate()
Dim cbc As CommandBarControl
Set cbc = CommandBars("Custom1").FindControl (, , "Custombutton1")
cbc.Enabled = Me.List16.Column(2)
End Sub
--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Hi,
I have a shortcut menu for use on a list box.
Some of the items in the list box can be exported, others
cant.
How can I enable/Disable the Export function on the menu,
dependent on the selected item?
Any help is much appreciated.
Cheers,
Steve
.