Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menubar - disable specific menu based on condition 1

Status
Not open for further replies.

DH

Programmer
Dec 8, 2000
168
Is it possible to disable a specific item/task on a menubar based on a condition?

Thanks.


 
yes, just add this code to whatever event you use to test for the condition. You need to know the name of the MenuBar and the Name or Caption of the Item on the MenuBar.

Dim cbr As CommandBar
Dim cbrCtl As CommandBarControl
' Set a reference to the Access menu bar
Set cbr = CommandBars("CommandBarName")
Set cbrCtl = cbr.Controls("CommandBarCaptionGoesHere")
' Set the Enabled Property to False
cbrCtl.Enabled = False
'or set it to True
' cbrCtl.Enabled = True
 
Also, ensure that you set a reference to the
Microsoft Office 8.0 Object Library (or 9.0)

PaulF
 
Thanks Paul - your example worked great.

How can I then enable/disable only one item from the drop down list of a menu on a menubar?

For example:

I have a menu bar named "MenuBarName" with a caption named "Caption" and then I have another caption I guess named "SubCaption" that appears as one of many items in the "Caption"

MenuBarName>Caption>Subcaption

I have tried experimenting with this but might not be on the right track. Is there a SubControls or something?

Thanks Again.


 
Private Sub form_load()
Dim cbr As CommandBar
Dim cbrCtl As CommandBarControl
' Set a reference to the Access menu bar
Set cbr = CommandBars("menubar")
Set cbrCtl = cbr.Controls("menucaption").Controls("submenucaption")


' Set the Enabled Property to False
cbrCtl.Enabled = True

'or set it to True
' cbrCtl.Enabled = True


End Sub
 
How do you disable all the items under menucaption?

How do you do a for...loop statement?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top