Admin rights

auntielo

Registered User.
Local time
Today, 16:34
Joined
Apr 8, 2017
Messages
20
Can you switch between admin and user rights? I only want admin rights when I am going in to edit something. Otherwise I just want to use it like a user.

I have a Start Menu form with an Admin button. I was hoping to block/hide most things unless I clicked Admin. Trying to protect the database from myself :)

Is this possible or something like it?
 
Well I'm tempted to say if you can't trust yourself should you be developing the db!

But actually I can see the point - for example to test the db as it would be for a standard user

Yes, easy enough to do providing users login (user name / password)

For example, add a boolean field called AdminRights with default = 0 (false)
If AdminRights = True then Admin button is visible, otherwise it is hidden

In your case, that means, you need 2 logins - standard & admin

HTH
 
Thanks for the restraint ;)

If I don't develop it, we won't have one. I have a huge spreadsheet (140 columns) and I need to manipulate data fast. I was complaining about it in February and someone suggested Access.... which I had never heard of before...

I don't know if I want to go the login route. Is there a way to hide the Navigation unless you enter a Password? I saw something like that here, but I didn't quite get it. I will see if I can find it again and post it.
 
To show/hide the nav pane, place these functions in a module

Code:
Public Function ShowNavigationPane() 

On Error GoTo ErrHandler

    DoCmd.SelectObject acTable, , True

Exit_ErrHandler:
    Exit Function
    
ErrHandler:
    MsgBox "Error " & Err.Number & " in ShowNavigationPane routine : " & Err.Description, vbOKOnly + vbCritical
    Resume Exit_ErrHandler

End Function


Public Function HideNavigationPane()

On Error GoTo ErrHandler

'only works for SDAManagers
    DoCmd.SelectObject acForm, , True
    DoCmd.SelectObject acQuery, , True
    DoCmd.SelectObject acReport, , True
    DoCmd.SelectObject acMacro, , True
    DoCmd.SelectObject acModule, , True
    DoCmd.SelectObject acTable, , True
    DoCmd.NavigateTo "acNavigationCategoryObjectType" 
    DoCmd.RunCommand acCmdWindowHide
    
  
Exit_ErrHandler:
    Exit Function
    
ErrHandler:
    MsgBox "Error " & Err.Number & " in HideNavigationPane routine : " & Err.Description, vbOKOnly + vbCritical
    Resume Exit_ErrHandler

End Function

If you want the db to open with the nav pane hidden by default, you could put HideNavigationPane function in an Autoexec macro to run at start up ... or change the settings in the database options

As for admin rights, I'm not sure there's any sensible way of doing this without a login procedure
 
There is of course the method of hiding the button that flip-flops the ability. It doesn't have to be a button. Turns out you can declare an OnClick event on a line or rectangle control. Then you can run code that would require a password to enable the feature so that a random click won't just open the doors wide enough for the proverbial Mac truck. But if you HAVE admin rights, that same object could turn them off without a password.

Note that if you do this, you will need a special routine to set "Ordinary" vs. "Admin" that can be called from various places. Either the form's OnLoad or OnCurrent should call the routine that does the "Ordinary" and only the OnClick routine would call the "Admin" case or the "Ordinary" case as appropriate to the moment. If this putative setup call is done from a switchboard form or dispatcher form that is unbound, then definitely use the OnLoad (since there will BE no OnCurrent.)
 
Hey ridders

If you want the db to open with the nav pane hidden by default, you could put HideNavigationPane function in an Autoexec macro to run at start up ... or change the settings in the database options

I have zero knowledge of macro, somehow vba made more sense. How would I add the function in my Autoexec macro?

Code:
OpenForm
Form Name           Start Menu
View                 Form
Filter Name
Where Condition
Data Mode
Window Mode         Normal
 
Hi The Doc Man

I am going to have to relook at this one in the morning. I can't quite get it. Love the idea though. And I am okay with the team editing it, as long as they are intending to, so the password might be perfect.

I really just want to make it as user friendly as possible or it loses it's value. To me as well. I don't want to keep having to open all the groups in my Nav Pane trying to find the right form :)
 
Hi

Final post for tonight - its late here!

Almost the only use for a macro is the autoexec macro

Here's a screen grab of mine with 3 items - you need the last one

However hiding the ribbon is also a good idea

Some more functions for you ...

Code:
Public Function HideRibbon()
    'could run at startup using Autoexec
    'however this also hides the QAT which makes printing reports tricky
     DoCmd.ShowToolbar "Ribbon", acToolbarNo
   '  DoCmd.ShowToolbar "PrintReport", acToolbarYes
End Function

Public Function ShowRibbon()
     DoCmd.ShowToolbar "Ribbon", acToolbarYes
End Function

Public Function ToggleRibbonState()

'hide ribbon if visible & vice versa
    CommandBars.ExecuteMso "MinimizeRibbon"
End Function

Public Function IsRibbonMinimized() As Boolean
    'Result: 0=normal (maximized), -1=autohide (minimized)

    IsRibbonMinimized = (CommandBars("Ribbon").Controls(1).Height < 100)
   ' Debug.Print IsRibbonMinimized
End Function
 

Attachments

  • Autoexec.PNG
    Autoexec.PNG
    9.7 KB · Views: 113
it isn't so straightforward though.

when a form opens, generally you only have a very broad brush. You can set the form to work "normally", or you can set it to "disallow edits", let's say.

Now if you what you really want is to allow some changes, but not all, then you either need two forms, one for a full user, and one for a restricted user, or you need a lot of code to manage the different sets of users.

It's equivalent to have a spreadsheet that is unprotected, or one that is completely protected, where what you really want is something in between.
 

Users who are viewing this thread

Back
Top Bottom