2016-09-28 115 views
-3

我不斷收到一個類型不匹配的錯誤,我不知道我在做什麼錯誤。類型不匹配的錯誤,我不知道該怎麼辦

這是我到目前爲止已經試過:

Private Sub Command1_Click() 
Dim UserLevel As Integer 

If IsNull(Me.txtLoginID) Then 
    MsgBox "Please Enter Login ID", vbInformation, "Login ID Required" 
    Me.txtLoginID.SetFocus 
ElseIf IsNull(Me.txtPassword) Then 
    MsgBox "Please Enter Password", vbInformation, "Password Required" 
    Me.txtPassword.SetFocus 
Else 
    If (IsNull(DLookup("UserLogin", "Accounts", "UserLogin='" & Me.txtLoginID.Value & "'"))) Or _ 
    (IsNull(DLookup("Password", "Accounts", "Password='" & Me.txtPassword.Value & "'"))) Then 
     MsgBox "Incorrect Login ID or Password" 
    Else 
     UserLevel = DLookup("UserSecurity", "Accounts", "UserLogin= '" & Me.txtLoginID.Value & "'") 
     DoCmd.Close 
      If UserLevel = admin Then 
     DoCmd.OpenForm "Administrator" 
    Else 
     DoCmd.OpenForm "Sales" 
     End If 
    End If 
End If 
+1

哪行引發錯誤? – Andre

回答

0

試着用的Nz更換您ISNULL:

If Nz(DLookup("UserLogin", "Accounts", "UserLogin='" & Me.txtLoginID.Value & "'")) Or _ 
Nz(DLookup("Password", "Accounts", "Password='" & Me.txtPassword.Value & "'")) Then 
    MsgBox "Incorrect Login ID or Password" 
相關問題