Results 1 to 5 of 5
  1. #1
    croydon is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    10

    Customized Toolbars


    I have created a toolbar using the Customize function. This is a toolbar with five options. Each of these options is a group that has a number of further options (i.e. opens various forms and reports).

    Depending on the user access level, I would like to disable some options from within VBA.

    I can't see how it is possible to read through the toolbar collections to identify the menu options and disable them.

    Any suggestions would be appreciated. Thanks.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Here's the method I use:
    Code:
    '-- Disable printer functions.  Any form needing the printer will enable it.
    Dim MyMenu As Object
    Set MyMenu = CommandBars("MyMenuName").Controls("File")
    '-- Page SetUp
    MyMenu.Controls(1).Enabled = False
    'PrintSetUp = MyMenu.Controls(1).Visible             '-- Save existing state
    'MyMenu.Controls(1).Visible = False
    '-- Print Preview
    MyMenu.Controls(2).Enabled = False
    'PrintPreview = MyMenu.Controls(2).Visible           '-- Save existing state
    'MyMenu.Controls(2).Visible = False
    '-- Print...
    'Printable = MyMenu.Controls(3).Enabled              '-- Save existing state
    MyMenu.Controls(3).Enabled = False

  3. #3
    croydon is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    10
    Thanks RuralGuy, I didn't think it was as simple as that. I had actually found a way to do this below:

    Dim Menu As Object, PMRMenu As Object, PMRItem As Object

    For Each Menu In Application.CommandBars
    If Menu.Name = "PMR" Then
    For Each PMRMenu In Menu.Controls
    If PMRMenu.BeginGroup = True Then
    For Each PMRItem In PMRMenu.Controls
    If PMRItem.Tag = 1 Then
    PMRItem.Enabled = False
    End If
    Next PMRItem
    End If
    Next PMRMenu
    End If
    Next Menu

    So for the customized menu named PMR, for each group, it checks the items and any found with a tag of 1 are disabled.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Are you ready to use the Solved thread tool on this thread yet?

  5. #5
    croydon is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    10
    Thread solved!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. customized menu bar
    By marianne in forum Access
    Replies: 13
    Last Post: 04-12-2009, 09:47 PM
  2. Customized Format for displaying record
    By wasim_sono in forum Reports
    Replies: 1
    Last Post: 10-10-2006, 09:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums