【问题标题】:type mismatch error i dont know what to do类型不匹配错误我不知道该怎么办
【发布时间】:2016-09-28 15:32:16
【问题描述】:

我不断收到类型不匹配错误,我不确定自己做错了什么。

这是我迄今为止尝试过的:

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

【问题讨论】:

  • 哪一行报错?

标签: ms-access vba


【解决方案1】:

尝试用 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"

【讨论】:

    猜你喜欢
    • 2013-11-06
    • 2012-02-01
    • 2021-06-21
    • 1970-01-01
    • 2013-03-30
    • 1970-01-01
    • 1970-01-01
    • 2021-08-11
    • 1970-01-01
    相关资源
    最近更新 更多