VBA / SQL问题访问

时间:2018-07-14 21:08:33

标签: sql vba ms-access-2016

我一直收到编译错误,提示无法在where行中找到txtlln。我是SQL / VBA的新手,所以不确定使用正确的表达式来完成这项工作。

Private Sub btnlledit_Click()
Dim strSQL As String
SQL = "UPDATE tblll " & _
      "SET [Component/Product] = '" & Forms!frmaddll!txtllcomponent & "',[HN] = '" & Forms!frmaddll!txtllhn & "' " & _          
      "WHERE [LLN] = '" & Forms!frmaddll!txtlln.value & "';"
debug.print sql
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
DoCmd.Requery

Me.Refresh 
End Sub

1 个答案:

答案 0 :(得分:2)

您的字符串连接似乎有一些问题。

Private Sub btnlledit_Click()
    Dim strSQL As String

    SQL = "UPDATE tblll " & _
          "SET [Component/Product] = '" & Forms!frmaddll!txtllcomponent & "' " & _
          "WHERE [LLN] = '" & Forms!frmaddll!txtlln.value & "';"
    debug.print sql
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True
    DoCmd.Requery

    Me.Refresh

End Sub