การกำหนดสิทธการเข้าใช้
Posted: Sat Jul 04, 2015 1:16 pm
ฟอรัม Excel, VBA และอื่นๆ ของคนไทยเพื่อประโยชน์ของทุกคนในจักรวาล (Forum Excel, VBA and others of Thai people for everyone in the universe.)
http://snasui.com/
Code: Select all
Private Sub bt_login_Click()
Dim UserLevel As String
Dim Fname As String
If IsNull(Me.txtuser) Then
MsgBox "Plaease enter User Name", vbInformation, "Login ID Required"
Me.txtuser.SetFocus
ElseIf IsNull(Me.txtpass) Then
MsgBox "Plaease enter Password", vbInformation, "Password Required"
Me.txtpass.SetFocus
Else
If (IsNull(DLookup("Em_User", "Employee", "Em_User = '" & Me.txtuser.Value & "' And Em_pass = '" & Me.txtpass.Value & "'"))) Then
MsgBox "UserName & Password Incurect"
Else
UserLevel = DLookup("Em_level", "Employee", "Em_User = '" & Me.txtuser.Value & "'")
Fname = DLookup("Em_Fname", "Employee", "Em_User = '" & Me.txtuser.Value & "'")
DoCmd.Close
If UserLevel = "admin" Then
DoCmd.OpenForm "Home"
Forms![Home]![showuser] = Fname
Forms![Home]![showlv] = UserLevel
Forms!Home.AllowDeletions = False
Forms!Home.AllowEdits = False
Else
DoCmd.OpenForm "Home"
DoCmd.OpenForm "Home"
If UserLevel = "User" Then
DoCmd.OpenForm "Home"
Forms![Home]![showuser] = Fname
Forms![Home]![showlv] = UserLevel
End If
End If
End If
End If