Disable navigation pane, not just minimize/hide it (1 Viewer)

jaitken0308

Registered User.
Local time
Today, 13:23
Joined
Jan 23, 2014
Messages
30
Hi,

I would like to disable the Navigation Pane completely, based on the security level of the user that logs in, of course.

I have code that checks their level (I'm an "Admin" and everyone else is a "User"). If they are a user, then it hides the ribbon and minimizes the nav pane. If the login is mine, it enables everything.

That works, but the only problem is that the user can just maximize the Nav Pane on their own and access all the tables, and I don't want that. I can't find any code that completely disables the pane.

I have this code connected to my login button on my login form:

Code:
If Security = "User" Then
    DoCmd.ShowToolbar "Ribbon", acToolbarNo
    DoCmd.NavigateTo "acNavigationCategoryObjectType"
    DoCmd.Minimize
Else
    DoCmd.ShowToolbar "Ribbon", acToolbarYes
    DoCmd.NavigateTo "acNavigationCategoryObjectType"
    DoCmd.Maximize
End If

Any help is appreciated. Thank you!



And to just edit my above post...

I can go to the options menu and disable the nav pane completely, so I know since only I have access to the ribbon, I could always go in each time and recheck the display nav pane option on that menu. But, that could be a little bit of a pain having to do that each time.

Also, I know I could finish the design and convert the DB to an MDE, but since my DB isn't broken up into a front/back end, I have to access that same DB everyone else uses, and if any changes need to be made, I don't want to have to use my backup, transfer over the changes any user made to the records, and then reconvert it back to an MDE each time.

If it's possible, I'd like to do all this using VBA. If they aren't an ADMIN user, then disable everything for them, but if I login, enable everything for me.
 
Last edited:

JHB

Have been here a while
Local time
Today, 20:23
Joined
Jun 17, 2012
Messages
7,732
Try the below code:
Code:
If Security = "User" Then
    DoCmd.ShowToolbar "Ribbon", acToolbarNo
    DoCmd.NavigateTo "acNavigationCategoryObjectType"
    DoCmd.RunCommand acCmdWindowHide
Else
    DoCmd.ShowToolbar "Ribbon", acToolbarYes
    DoCmd.SelectObject acTable, , True
End If
 

jaitken0308

Registered User.
Local time
Today, 13:23
Joined
Jan 23, 2014
Messages
30
JHB, thanks for the reply.

I've tried variations of that code, and I just tried the specific code you posted, but it doesn't work. Doesn't seem to do anything actually. The ribbon hide/unhide has always worked, but the code to hide/unhide the Navigation Pane doesn't work.

I'm running Access 2010 by the way. Does that change things with that code?
 

JHB

Have been here a while
Local time
Today, 20:23
Joined
Jun 17, 2012
Messages
7,732
Hmm - try if it works in the attached database, it does by me.
 

Attachments

  • NavOpenOrClose.accdb
    480 KB · Views: 577

Ari

Registered User.
Local time
Today, 11:23
Joined
Oct 22, 2011
Messages
139
Hi

Why not just change the extension ACCDB to ACCDR ?
 

jaitken0308

Registered User.
Local time
Today, 13:23
Joined
Jan 23, 2014
Messages
30
Hmm - try if it works in the attached database, it does by me.

Sorry for the late reply. I was out of the office Friday.

I tried to download your attached DB and it told me it was corrupted and would not open. I've seen the code you shared and tried it multiple times, and nothing seems to happen. I wonder what I'm doing wrong since it seems to work for everyone else.

Thanks again for your help. Do you have any other suggestions I could try?
 

jaitken0308

Registered User.
Local time
Today, 13:23
Joined
Jan 23, 2014
Messages
30
Hi

Why not just change the extension ACCDB to ACCDR ?

I could do this, but that means I would have to change the extension every time I wanted to make changes to the DB, correct? It would lock it down to a runtime version for everyone, right?
 

JHB

Have been here a while
Local time
Today, 20:23
Joined
Jun 17, 2012
Messages
7,732
..
I tried to download your attached DB and it told me it was corrupted and would not open...
I downloaded my database and it wasn't corrupt by me, (and code worked).
Do you've another computer you could try the code on?
 

jaitken0308

Registered User.
Local time
Today, 13:23
Joined
Jan 23, 2014
Messages
30
I downloaded my database and it wasn't corrupt by me, (and code worked).
Do you've another computer you could try the code on?

I tried on my work computer, so it may be a problem here.

But, I do have another question.

I did read that if you try to call this code (the code you shared above) from a modal form, then it will not work. My login form is modal. When reading, it said that this can be overcome, but it did not say how. Any ideas?
 

jaitken0308

Registered User.
Local time
Today, 13:23
Joined
Jan 23, 2014
Messages
30
I tried on my work computer, so it may be a problem here.

But, I do have another question.

I did read that if you try to call this code (the code you shared above) from a modal form, then it will not work. My login form is modal. When reading, it said that this can be overcome, but it did not say how. Any ideas?

I answered my own question. I just disabled the modal property of the form. Works like a charm. Thanks for all your help.
 

Frothingslosh

Premier Pale Stale Ale
Local time
Today, 14:23
Joined
Oct 17, 2012
Messages
3,276
For future reference, you can also use AutoKeys to selectively disable F11 based on code. Basically, have it RunCode for F11, and have the code either show the NavPane if the user is an admin or do nothing if they're not.

Out of curiosity, are you doing anything about the shift-bypass?
 

jaitken0308

Registered User.
Local time
Today, 13:23
Joined
Jan 23, 2014
Messages
30
For future reference, you can also use AutoKeys to selectively disable F11 based on code. Basically, have it RunCode for F11, and have the code either show the NavPane if the user is an admin or do nothing if they're not.

Out of curiosity, are you doing anything about the shift-bypass?


Forgive me, but what is the "Shift-Bypass" you speak of?
 

Robster

Registered User.
Local time
Today, 11:23
Joined
Mar 13, 2014
Messages
60
I had a similar issue. I set the Login form to hide the Navbar and Tables on load. Then on the next form, once you had entered valid login details, you can show them
I created security levels, SecLevel, with '4' being admin and the following works for me in Access2010.
When loading the form after Login I see the Nav Pane but users can not.

If Me.SecLevel = 4 Then DoCmd.ShowToolbar "Ribbon", acToolbarYes
If Me.SecLevel = 4 Then DoCmd.SelectObject acTable, , True
 

Frothingslosh

Premier Pale Stale Ale
Local time
Today, 14:23
Joined
Oct 17, 2012
Messages
3,276
Forgive me, but what is the "Shift-Bypass" you speak of?

If you hold down the SHIFT key while starting up an access database, it bypasses the entire start-up procedure. It's similar to starting up in safe mode. NOTHING gets run - the AutoExec, the AutoKeys, the startup options, nada.

Very, very few non-developers know about it, but it is there. If you don't think it will be an issue, no big deal. If you do need to worry about it, you'll need to disable that. Gimme a sec and I'll find and edit in a link to code that can toggle it on and off.

Edit: HERE you go.

Keep in mind that it's a toggle, so you'll need either a password-protected option to toggle it, or else a "hidden" button somewhere. (Or a combination of both!)
 
Last edited:

jaitken0308

Registered User.
Local time
Today, 13:23
Joined
Jan 23, 2014
Messages
30
If you hold down the SHIFT key while starting up an access database, it bypasses the entire start-up procedure. It's similar to starting up in safe mode. NOTHING gets run - the AutoExec, the AutoKeys, the startup options, nada.

Very, very few non-developers know about it, but it is there. If you don't think it will be an issue, no big deal. If you do need to worry about it, you'll need to disable that. Gimme a sec and I'll find and edit in a link to code that can toggle it on and off.

Edit: HERE you go.

Keep in mind that it's a toggle, so you'll need either a password-protected option to toggle it, or else a "hidden" button somewhere. (Or a combination of both!)

Awesome! Thank you. Would have never thought of that. I disabled the shortcut keys, but had no idea there was a bypass. Thanks again!
 

Users who are viewing this thread

Top Bottom