I have navigation form with 2 tabs I'd like to limit access to users with certain type of account.
There are 2 tables in database that contains user names and types of accounts (tblSecurityLevel and tblUser), and they are used to set user name, login and security level.
It works this way: when you open form, it checks if PC name corresponds to name in UserLogin field (tblUser), if it does it gives appropriate access level depending on set user security, if PC name is not on the list user will be logged as guest.
So far, I used this code and it works great for limiting access to 1 tab:
Is there a way to expand the code and add second tab (or even third) with this table structure (I'd like to be able to keep login which 1st checks for pc name).
I hope I've been clear in explaining the problem.
Any help is appreciated!
There are 2 tables in database that contains user names and types of accounts (tblSecurityLevel and tblUser), and they are used to set user name, login and security level.
It works this way: when you open form, it checks if PC name corresponds to name in UserLogin field (tblUser), if it does it gives appropriate access level depending on set user security, if PC name is not on the list user will be logged as guest.
So far, I used this code and it works great for limiting access to 1 tab:
Code:
Private Sub Form_Load()
Dim UserLogin As String
Dim userLevel As Integer
UserLogin = Environ("Username")
Me.TxtLogin = UserLogin
If IsNull(DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.TxtLogin & "'")) Then
Me.TxtLogin = "Guest"
Else
userLevel = DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.TxtLogin & "'")
If userLevel = 1 Then
Me.DodajPredmet.Enabled = True
Else
Me.DodajPredmet.Enabled = False
End If
End If
End Sub
Is there a way to expand the code and add second tab (or even third) with this table structure (I'd like to be able to keep login which 1st checks for pc name).
I hope I've been clear in explaining the problem.
Any help is appreciated!