Toolbars and Security

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MacDermott

    #1

    Toolbars and Security

    I have an MDB file which is secured using a custom MDW file.

    I'd like to have most users see only the shortened menu you see when you set
    the Startup option "Allow full menus" to False.

    But the administrator should be able to see the full menus, plus toolbars.
    The shift-bypass key is disabled; too many people know about it.

    If I allow toolbars at startup, I can't seem to set the visible property of
    either the "Form View" or "Database" toolbars to False programmaticall y.

    And if I don't allow toolbars at startup, I can't set it to True
    programmaticall y.
    ("Can't" means that nothing happens when I try to execute this code.)

    Any ideas on how to implement this gracefully & efficiently?
    (e.g. reset the database property, close the database, then re-open it
    is neither graceful nor efficient.)

    TIA
    - Turtle


  • Phil Stanton

    #2
    Re: Toolbars and Security

    Can't remember what the enclosed code does, but I think there was a field on
    the switchboard called CloseOK which was changed according to who was using
    the database.

    Might help ... and there again

    Phil


    Option Compare Database
    Option Explicit
    Global ReturnValue
    Global HasExtra As Boolean

    Function RefreshToolbar( ) ' Ensures the correct toolbar is shewn
    after a resize
    With CodeContextObje ct
    If .MenuBar = "" Then Exit Function
    ReturnValue = ShowTool(.MenuB ar) ' Show the toolbar
    End With

    End Function
    Function ShowTool(ToolBa r As String)

    Dim Cbar As CommandBar
    Dim CloseOK As Byte

    If Isloaded("Switc hboard") Then
    CloseOK = Forms!switchboa rd!CloseOK
    Else
    CloseOK = 1
    End If

    For Each Cbar In CommandBars
    If Cbar.Name = ToolBar Then ' Toolbar to show
    ReturnValue = HideTool(Cbar.N ame, True) ' Show it
    Else
    ' If "Menu Bar" visible and Not protected, don't hide it
    If Cbar.Name = "Menu Bar" And Cbar.Visible = True And CloseOK =
    1 Then
    ReturnValue = HideTool(Cbar.N ame, True) ' Don't Hide it
    Else
    ReturnValue = HideTool(Cbar.N ame, False) ' Hide it
    End If
    End If
    Next

    End Function
    Function OpnFrm(FrmName As String, ToolBar As String, Size As Byte)

    DoCmd.SelectObj ect acForm, FrmName, True
    If Size = 1 Then
    DoCmd.Maximize
    Else
    DoCmd.Restore
    End If

    If ToolBar = "" Then Exit Function

    ReturnValue = ShowTool(ToolBa r) ' Show the toolbar

    End Function

    Function HideAllToolBars ()

    Dim Cbar As CommandBar
    Dim CloseOK As Byte

    If Isloaded("Switc hboard") Then
    CloseOK = Forms!switchboa rd!CloseOK
    Else
    CloseOK = 1
    End If

    For Each Cbar In CommandBars
    ' If "Menu Bar" visible and Not protected, don't hide it
    If Cbar.Name = "Menu Bar" Then
    Cbar.Protection = msoBarNoProtect ion ' No protection to
    allow hiding
    If Cbar.Visible = True And CloseOK = 1 Then
    ReturnValue = HideTool(Cbar.N ame, True) ' Don't Hide it
    Else
    ReturnValue = HideTool(Cbar.N ame, False) ' Hide it
    End If
    Cbar.Protection = msoBarNoChangeV isible
    Else
    ReturnValue = HideTool(Cbar.N ame, False) ' Hide it
    End If
    Next Cbar


    End Function
    Function HideTool(ToolBa rName As String, Show As Boolean)

    On Error Resume Next ' No toolbar
    If Show = False Then
    DoCmd.ShowToolB ar ToolBarName, acToolbarNo ' Hide Toolbar
    Else
    DoCmd.ShowToolB ar ToolBarName, acToolbarYes ' Show Toolbar
    End If
    End Function

    "MacDermott " <macdermott@nos pam.com> wrote in message
    news:zSfDc.2839 8$Y3.2177@newsr ead2.news.atl.e arthlink.net...[color=blue]
    > I have an MDB file which is secured using a custom MDW file.
    >
    > I'd like to have most users see only the shortened menu you see when you[/color]
    set[color=blue]
    > the Startup option "Allow full menus" to False.
    >
    > But the administrator should be able to see the full menus, plus toolbars.
    > The shift-bypass key is disabled; too many people know about it.
    >
    > If I allow toolbars at startup, I can't seem to set the visible property[/color]
    of[color=blue]
    > either the "Form View" or "Database" toolbars to False programmaticall y.
    >
    > And if I don't allow toolbars at startup, I can't set it to True
    > programmaticall y.
    > ("Can't" means that nothing happens when I try to execute this code.)
    >
    > Any ideas on how to implement this gracefully & efficiently?
    > (e.g. reset the database property, close the database, then re-open it
    > is neither graceful nor efficient.)
    >
    > TIA
    > - Turtle
    >
    >[/color]


    Comment

    Working...