Solved User level Disable navigation button/hide content in navigation button (1 Viewer)

ATF

New member
Local time
Today, 15:47
Joined
Jul 25, 2022
Messages
4
Hi, may I know how to Disable navigation button/hide content in navigation button in certain user ?
when log into guest for first time can still see tier 1 details even though not supposed to?
how can it be done , is it possible to hide tier 1 data in datasheet for the user that not supposedly to see it?
 

Attachments

  • 2.PNG
    2.PNG
    15 KB · Views: 98
  • 3.PNG
    3.PNG
    36.4 KB · Views: 104
  • 1.PNG
    1.PNG
    32.8 KB · Views: 91
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:47
Joined
Feb 28, 2001
Messages
27,401
See this article, part 3, for the VBA to hide the ribbon and navigation pane.


See this article on hiding the database window.


You must design a "control" form - often a switchboard or dispatcher form where you click a button to trigger ANOTHER form to perform a function. People can see the list of buttons but not the stuff underneath it. As to the "logging in guest for the first time" this depends on how you intend to identify the guest. What did you have in mind and what is your network environment? (e.g. total chaos network that is entirely peer-to-peer, simple local office network based only on a smart router, formal domain with real domain controller, insane bunch of IT guys with bullwhips looking over your shoulder?)

Once you have identified a user, you can determine that user's role (level of access) if you have a user table. There are ways for forms to be able to look up this information constructively, but you need to address what your environment will allow.
 

isladogs

MVP / VIP
Local time
Today, 08:47
Joined
Jan 14, 2017
Messages
18,275
The links provided in post #2 tell you how to hide the navigation pane, ribbon etc but neither are relevant to your question.

I suggest you open your form using 'open args' where it depends on the user level.
In your calling form, use code like this

Code:
user level = .... (same code as in your screenshot)
DoCmd.OpenForm "YourFormName",,,,,,userlevel

Now change the start of your Form_Load event to

Code:
Private Sub Form_Load()

Select Case Me.OpenArgs

Case 1
...etc as in your screenshot

Two other points
1. You should explicitly declare all variables. Use Option Explicit as the second line in all code modules
2. In future please place your code in a code block as above rather than a screenshot
 
  • Like
Reactions: ATF

ATF

New member
Local time
Today, 15:47
Joined
Jul 25, 2022
Messages
4
Here I drop my project.
if you log in with (Guest), then you click on datasheet button, user still can see what inside the tier 1 data.

username : guest
pass ; 1234

username : Admin
pass : admin
 

Attachments

  • Database.accdb
    2.4 MB · Views: 95

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:47
Joined
May 7, 2009
Messages
19,249
check if this is what you want.
i just copy your subform.
on the other copy i just delete tier 1 button.
depending on the AccessLevel i change the SourceObject of the navigationsubform.
 

Attachments

  • Database.accdb
    3 MB · Views: 106
  • Like
Reactions: ATF

isladogs

MVP / VIP
Local time
Today, 08:47
Joined
Jan 14, 2017
Messages
18,275
I've spent about half an hour on this and made it do much of what you asked
You hadn't implemented any of the things I mentioned in post #3 -
I've done part of this for you on the forms Login, Main Page and sun Navigation Datasheet but much more still needs to be changed

I've just modified the existing subform rather than create duplicate subforms as @arnelgp says he's done,

I've not looked at your tables
There was much wrong with your forms. For example
  • variables not explicitly declared
  • spaces in object & field names
Hopefully, you should be able to continue with required changes yourself as I'm out of time and you will learn more by doing it yourself
 

Attachments

  • ATF_v2.zip
    218.1 KB · Views: 99
  • Like
Reactions: ATF

ATF

New member
Local time
Today, 15:47
Joined
Jul 25, 2022
Messages
4
I've spent about half an hour on this and made it do much of what you asked
You hadn't implemented any of the things I mentioned in post #3 -
I've done part of this for you on the forms Login, Main Page and sun Navigation Datasheet but much more still needs to be changed

I've just modified the existing subform rather than create duplicate subforms as @arnelgp says he's done,

I've not looked at your tables
There was much wrong with your forms. For example
  • variables not explicitly declared
  • spaces in object & field names
Hopefully, you should be able to continue with required changes yourself as I'm out of time and you will learn more by doing it yourself
Thank you so much for your time, i really appreciate your help.
im sorry, this is my first time to do this project, i dont have any basic knowlegde about VBA and programming. I just learn from youtube and read forum only. that why my variables are so messy!
 

ATF

New member
Local time
Today, 15:47
Joined
Jul 25, 2022
Messages
4
check if this is what you want.
i just copy your subform.
on the other copy i just delete tier 1 button.
depending on the AccessLevel i change the SourceObject of the navigationsubform.
Thank you Arnelgp! I like it. Simple and easy to understand! Thank you for you time.
 

isladogs

MVP / VIP
Local time
Today, 08:47
Joined
Jan 14, 2017
Messages
18,275
Thank you so much for your time, i really appreciate your help.
im sorry, this is my first time to do this project, i dont have any basic knowlegde about VBA and programming. I just learn from youtube and read forum only. that why my variables are so messy!
Coding navigation forms really isn't an example that is suitable for beginners.
Glad you have a solution you can understand but, in general, I recommend you avoid having a different subform for each case.
Much more work to setup and to maintain.
Simple isn't always best
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:47
Joined
May 7, 2009
Messages
19,249
if you need to make Modification to your "Datasheet" subform, you modify the "Original" one (with tier 1 to tier 4 tabs).
after modifying, delete the "second" copy (the one without tier 1).
make a copy of the original and on the copy delete "tier 1" tab again and rename the subform again.
again, very simple steps.
 
  • Like
Reactions: ATF

Users who are viewing this thread

Top Bottom