Reputation: 959
I had this project where I have to make a program with a login and different levels of access according to which user loged in. So i made the login form and after that i had this form where it have three sub-forms, each labeled level_1-3. The idea is if the user has access level 1 the two sub-forms will be disabled and the first form only will be enabled.
the code i used looks something like this
If Not rs.EOF Then
Acesslevel = DLookup("[Access_level]", "managers_data", "username.Value")
MsgBox " Welcome " & username.Value & ". Acess level " & Acesslevel & " Granted!!"
DoCmd.Close
If Acesslevel = 1 Then
DoCmd.OpenForm "Home"
x
If Acesslevel = 2 Then
DoCmd.OpenForm "Home"
y
If Acesslevel = 2 Then
DoCmd.OpenForm "Home"
z
so my question is what code should i insert in places of x so that the two sub-forms (sub-form level_2 and level_3 are disabled and level_1 is enabled) and the same question goes for y and z. the name of the form is home. and i am using ms access 2013. Any help will be appreciated, thanks.
Upvotes: 0
Views: 2542
Reputation: 55806
It could be:
<snip>
DoCmd.Close
DoCmd.OpenForm "Home"
Forms!Home!SubformControlX.Enabled = False
Forms!Home!SubformControlY.Enabled = False
Forms!Home!SubformControlZ.Enabled = False
Select Case Acesslevel
Case 1
Forms!Home!SubformControlX.Enabled = True
Case 2
Forms!Home!SubformControlY.Enabled = True
Case 3
Forms!Home!SubformControlZ.Enabled = True
End Select
Upvotes: 1