在vba中出现“expected:end of statement”错误

yhuiod9q  于 2021-08-09  发布在  Java
关注(0)|答案(2)|浏览(517)

我正在microsoft access中建立一个登录屏幕“用户名”是我得到错误代码后突出显示的内容。
代码如下:

Private Sub btnLogin_Click()
    Dim rs As DAO.Recordset
    Dim SQL As String

    SQL = "SELECT * FROM Users WHERE * "username = '" + Me.txtUserName + "'"

    End With

    Set rs = CurrentDb.OpenRecordset(SQL)

    If rs.EOF Then
        IncorrectUserNameStyle
        Exit Sub
    End If

    End If
End Sub
bgtovc5b

bgtovc5b1#

你的绳子不好看,这个怎么样:

Private Sub btnLogin_Click()
    Dim rs As DAO.Recordset
    Dim SQL As String

    SQL = "SELECT * FROM Users WHERE username = '" + Me.txtUserName + "'"

    ' End With -- what's this?

    Set rs = CurrentDb.OpenRecordset(SQL)

    If rs.EOF Then
        'IncorrectUserNameStyle -- what's this?
        MsgBox("Username not found", 0)
        Exit Sub
    End If

    ' End If -- what's this?
End Sub
0qx6xfy6

0qx6xfy62#

看起来查询中有一个输入错误(a) " 在不应该的地方),标记如下:

SQL = "SELECT * FROM Users WHERE * "username = '" + Me.txtUserName + "'"
                                   ^ end of string
                                 ^ probably a mistake

相关问题