2016-09-28 92 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"