By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

Toolbars and Security

P: n/a
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 programmatically.

And if I don't allow toolbars at startup, I can't set it to True
programmatically.
("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
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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 CodeContextObject
If .MenuBar = "" Then Exit Function
ReturnValue = ShowTool(.MenuBar) ' Show the toolbar
End With

End Function
Function ShowTool(ToolBar As String)

Dim Cbar As CommandBar
Dim CloseOK As Byte

If Isloaded("Switchboard") Then
CloseOK = Forms!switchboard!CloseOK
Else
CloseOK = 1
End If

For Each Cbar In CommandBars
If Cbar.Name = ToolBar Then ' Toolbar to show
ReturnValue = HideTool(Cbar.Name, 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.Name, True) ' Don't Hide it
Else
ReturnValue = HideTool(Cbar.Name, False) ' Hide it
End If
End If
Next

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

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

If ToolBar = "" Then Exit Function

ReturnValue = ShowTool(ToolBar) ' Show the toolbar

End Function

Function HideAllToolBars()

Dim Cbar As CommandBar
Dim CloseOK As Byte

If Isloaded("Switchboard") Then
CloseOK = Forms!switchboard!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 = msoBarNoProtection ' No protection to
allow hiding
If Cbar.Visible = True And CloseOK = 1 Then
ReturnValue = HideTool(Cbar.Name, True) ' Don't Hide it
Else
ReturnValue = HideTool(Cbar.Name, False) ' Hide it
End If
Cbar.Protection = msoBarNoChangeVisible
Else
ReturnValue = HideTool(Cbar.Name, False) ' Hide it
End If
Next Cbar
End Function
Function HideTool(ToolBarName As String, Show As Boolean)

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

"MacDermott" <ma********@nospam.com> wrote in message
news:zS*****************@newsread2.news.atl.earthl ink.net...
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 programmatically.

And if I don't allow toolbars at startup, I can't set it to True
programmatically.
("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

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.