J
JOM
I would like to enable and disable some of the buttons depending on access
level one has. in my Employee table, I have the following fields EName,
loginID, AccessLevel -- 1 grants all rights while 2 limits the rights ti what
can be accessed. How will I code it so that if your loginID isnot in the
database it provides the msgbox provided below and when one clicks ok, it
should exit.
So on my switchboard in the open event procedure, I have the following
Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.
' Move to the switchboard page that is marked as the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True
AL = DLookup("AccessLevel", "TblEmployee", "LoginID = '" &
Environ("username") & "' ")
If AL = 1 Then
With Me
.Option1.Enabled = True
.Option2.Enabled = True
.Option3.Enabled = True
.Option4.Enabled = True
End With
ElseIf AL = 2 Then
With Me
.Option1.Enabled = True
.Option2.Enabled = False
.Option3.Enabled = False
.Option4.Enabled = True
End With
Else
If IsNull(AL) Then
With Me
.Option1.Enabled = True
.Option2.Enabled = False
.Option3.Enabled = False
.Option4.Enabled = False
End With
End If
MsgBox "You do not have sufficient access to use this database/application" _
& Chr(13) & "See management", vbCritical, "Insufficient Database Access"
End If
End Sub
level one has. in my Employee table, I have the following fields EName,
loginID, AccessLevel -- 1 grants all rights while 2 limits the rights ti what
can be accessed. How will I code it so that if your loginID isnot in the
database it provides the msgbox provided below and when one clicks ok, it
should exit.
So on my switchboard in the open event procedure, I have the following
Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.
' Move to the switchboard page that is marked as the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True
AL = DLookup("AccessLevel", "TblEmployee", "LoginID = '" &
Environ("username") & "' ")
If AL = 1 Then
With Me
.Option1.Enabled = True
.Option2.Enabled = True
.Option3.Enabled = True
.Option4.Enabled = True
End With
ElseIf AL = 2 Then
With Me
.Option1.Enabled = True
.Option2.Enabled = False
.Option3.Enabled = False
.Option4.Enabled = True
End With
Else
If IsNull(AL) Then
With Me
.Option1.Enabled = True
.Option2.Enabled = False
.Option3.Enabled = False
.Option4.Enabled = False
End With
End If
MsgBox "You do not have sufficient access to use this database/application" _
& Chr(13) & "See management", vbCritical, "Insufficient Database Access"
End If
End Sub