来自textbox中字符串的docmd.runSQL

时间:2016-09-27 12:34:58

标签: sql ms-access access-vba

我在表单上有一个文本框,其中包含以下内容:

"UPDATE Dialogs SET Dialogs.Message = 'blah blah' " &     vbCrLf & _
"WHERE (((Dialogs.Error)=1));"

现在我想通过执行以下操作来执行:

    Const strcLineEnd = " "" & vbCrLf & _" & vbCrLf & """"
    If IsNull(Me.SQLStatement) & Me.txtqrytype = "UPDATE" Then
    Beep
    Else
    strSQL = Me.SQLStatement
    strSQL = Replace(strSQL, """", """""")  'Double up any quotes.
    strSQL = Replace(strSQL, vbCrLf, strcLineEnd)
    strSQL = """" & strSQL & """"
    Me.txtVBA = strSQL
    Me.txtVBA.SetFocus

    Dim coded As String
    coded = Me.txtVBA


    DoCmd.RunSQL coded


End If

但是我收到以下错误:无效的sql语句需要“删除”,“插入”,“选择”,“更新”。

任何想法?

0 个答案:

没有答案