Different users on one single db (1 Viewer)

mounty76

Registered User.
Local time
Today, 15:00
Joined
Sep 14, 2017
Messages
341
Hello!

I have a db that I want to keep as a single db, not a split db.

Is it possible to have two different users, one has full access (me) and the other has restricted access/slightly different forms?

Is it possible to have VBA to change the visibility of certain items in certain forms based on who logs in? I'm not so concerned about the rest of the access, it is really so when the other person logs on he cannot see certain data that I can.

Also does anyone have any neat code/forms for username/password logins? :)

Thanks in advance
 

mounty76

Registered User.
Local time
Today, 15:00
Joined
Sep 14, 2017
Messages
341
Hi isladogs,

Thanks for this. No it will only ever be one user using it at one time, Ive made split database before with 30 users and it was great, but this is a much smaller application that will only ever have two users and it wont be at the same time.

Cheers
 

mounty76

Registered User.
Local time
Today, 15:00
Joined
Sep 14, 2017
Messages
341
Hi isladogs,

Login in is great, much appreciated. So next I have to add some code to each of the forms that I want to change the visibility of certain parts, sorry my code is very poor, I'm guessing something along the lines of:

EventOnLoad

If Current User AccessLevel = 1 Then

[Form].[ControlBox Name1].Visible=False
[Form].[ControlBox Name2].Visible=False
[Form].[ControlBox Name3].Visible=False
Etc.

Else

OpenForm

Could you please point me in the right direction for the code? Also if the code changes the visibility when a level 3 user logs in (me) will the db still be storing the visibility values from the previous user?

Thanks in advance
 

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,216
Thanks DBG. That saves me needing to explain much of the approach.
The user level is determined when each user logs in.
If all you are concerned about is whether certain controls are visible/hidden, there will be no issues.

However, there could be an issue if you want to add additional security such as disabling full menus and the shift bypass. Certain security measures require the app to be reopened twice before the action takes effect. If this is the case, you really should reconsider splitting the database.

Just to add that the Tag property is very useful if you have several controls that you want to hide (or show) depending on the user level. For an example app showing how to manage controls using the Tag property, see https://www.access-programmers.co.uk/forums/showthread.php?t=293439
 
Last edited:

mounty76

Registered User.
Local time
Today, 15:00
Joined
Sep 14, 2017
Messages
341
Hi isladogs,

Thanks for this, I like the tag approach. I copied your module over and tagged some text boxes and a command button but I got the following error when it tried to run:

'Can't hide a control that has a focus'

I reduced all the tagged items down to one text box but still got the same error?

Any ideas?
 

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,216
Add a line to first set the focus to a control that you don't want to hide

Me.somecontrolname.SetFocus
 

mounty76

Registered User.
Local time
Today, 15:00
Joined
Sep 14, 2017
Messages
341
Still getting setfocus error, my code is:

Private Sub Form_Load()

Me.Expr1.SetFocus

If Me.Expr1 = "Normal" Then
ShowControls False, "A"
Else
ShowControls True, "A"
End If
End Sub

:banghead:
 

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,216
First of all Expr1 sounds like as query field NOT a form control.
Make sure you set focus to a textbox or similar on the form that you don't want to hide. Make sure that control either has no tag property value or a different tag value. In your case, not tag="A"
 

Users who are viewing this thread

Top Bottom