2017-01-31 8 views
0

私のログインを保護するためにこのコードを使用しましたが、私は2つのユーザ名と2つのパスワードを持っているなど、パスワードに問題がありました...ユーザ名を使用すると、 ...誰もがここに...私が使用したコードを助けることができる...ユーザレベルMS Access 2010

Private Sub cmdmsk_Click() 
    Dim UserLevel As Integer 
    Me.cmdmsk.SetFocus 

    If IsNull(Me.txtuser) Then 
     MsgBox "plis enter username", vbInformation, "Username needs to Login" 
     Me.txtuser.SetFocus 
    ElseIf IsNull(Me.txtpass) Then 
     MsgBox "plis enter you password", vbInformation, "Password needs to login" 
     Me.txtpass.SetFocus 
    Else 
     'process the job 
     If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.txtuser.Value & "'"))) Or _ 
     (IsNull(DLookup("Password", "tblUser", "Password ='" & Me.txtpass.Value & "'"))) Then 
      MsgBox "wrong pass or username" 
     Else 


      UserLevel = DLookup("UserSecurity", "tblUser", "UserLogin = '" & Me.txtuser.Value & "'") 



        If UserLevel = "1" Then 

         MsgBox "Cangratulations ^_^" 
         DoCmd.Close 
         DoCmd.OpenForm "MENU" 

         Else 


         DoCmd.Close 
         DoCmd.OpenForm "INPUT" 
      End If 
      End If 
      End If 

    End Sub 

答えて

0

1は唯一見上げるください:

Private Sub cmdmsk_Click() 

    Dim UserLevel As Variant 

    Me!cmdmsk.SetFocus 

    If IsNull(Me!txtuser.Value) Then 
     MsgBox "Please enter your username.", vbInformation, "Missing Username" 
     Me!txtuser.SetFocus 
    ElseIf IsNull(Me!txtpass.Value) Then 
     MsgBox "Please enter your password", vbInformation, "Missing Password" 
     Me!txtpass.SetFocus 
    Else 
     'process the job 
     UserLevel = DLookup("UserSecurity", "tblUser", _ 
      "[UserLogin] = '" & Me!txtuser.Value & "' And [Password] = '" & Me!txtpass.Value & "'") 

     If IsNull(UserLevel) Then 
      MsgBox "Incorrect username or password.", vbInformation, "Login" 
     Else 
      If UserLevel = "1" Then 
       DoCmd.OpenForm "MENU" 
      Else 
       DoCmd.OpenForm "INPUT" 
      End If 
      DoCmd.Close 
     End If 
    End If 

End Sub 
+0

はそれが@Gustavの作品をありがとう – RPM

関連する問題