The following code requires a reference to Mictosoft OFFICE 9.0 object library. (Office library, not Access)
Copy the following to a module
Notes first: The custom menu bar this controls is called 'TicketWizz'(Substitute your menu bar name)
The functions SetPrintToolsOff() SetPrintToolsOn()
enables and disablies the second menu item on the menu bar
SetTicketWizzOff() SetTicketWizzOn()
enables and disablies the forth item in the list on the first menu item on the menu bar
Just call these functions from your log on screen or where ever
If userlevel = dumbass then
Call SetPrintToolsOff
Else
Call SetPrintToolsOn
End If
Option Compare Database
Option Explicit
Dim MyBar As Variant
Public Function CommandbarEnable(Cmdbar As CommandBar, CmdbarEnabled As Boolean, TopLevel As Integer, Optional Sublevel As Integer)
Dim SubCommandbar
On Error GoTo Err_CommandBarEnable
'If the command bar is not visible, make it so.
If Cmdbar.Visible = False Then Cmdbar.Visible = True
'If no menu item on a submenu is selected for enabling\disabling,
'enable\disable the top level menu choice only.
If IsMissing(Sublevel) Or Sublevel = 0 Then
Cmdbar.Controls(TopLevel).Enabled = CmdbarEnabled
'If a menu item on a submenu is selected for
'enabling\disabling, do so now.
Else
Set SubCommandbar = Cmdbar.Controls(TopLevel)
SubCommandbar.Controls(Sublevel).Enabled = CmdbarEnabled
End If
Exit_CommandBarEnable:
Exit Function
Err_CommandBarEnable:
MsgBox "Error " & CStr(Err) & " " & Err.Description & _
" has occurred in the CommandBarEnable Function", vbOKOnly, _
"Error Detected"
Resume Exit_CommandBarEnable
End Function
Public Function SetPrintToolsOff()
'Disables the 'Design Tools' command on the menu bar
MyBar = CommandbarEnable(CommandBars("TicketWizzPrint"), False, 2)
End Function
Public Function SetPrintToolsOn()
'Enables the 'Design Tools' command on the menu bar
MyBar = CommandbarEnable(CommandBars("TicketWizzPrint"), True, 2)
End Function
Public Function SetTicketWizzOff()
'Disables the 'TicketWizz' menu command on the menu bar if the program trial period ends
MyBar = CommandbarEnable(CommandBars("TicketWizzPrint"), False, 1, 4)
End Function
Public Function SetTicketWizzOn()
'Disables the 'TicketWizz' menu command on the menu bar if the program trial period ends
MyBar = CommandbarEnable(CommandBars("TicketWizzPrint"), True, 1, 4)
End Function
HTH
Dave