在VBA ACCESS中更新表

时间:2013-04-16 11:36:24

标签: sql vba access-vba

我需要用vba update语句帮助解决我的问题:

在我的表单中,我有一个点击表单,当我点击它时执行此程序:

Dim strSQL As String
 Dim rst As New ADODB.Recordset

  strSQL = "UPDATE dbo.Firma_test SET Fax = " & Me![subforma_companie].Form!fax & _
          "[E-mail] = " & Me![subforma_companie].Form!email & _
          "WHERE Company_Code = " & Me![subforma_companie].Form!Cod

当我执行时,我告诉我他没有看到电子邮件字段,我该怎么办?

1 个答案:

答案 0 :(得分:2)

WHERE子句之前需要一个空格:

strSQL = "UPDATE dbo.Firma_test SET Fax = " & Me![subforma_companie].Form!fax & _
      ", [E-mail] = '" & Me![subforma_companie].Form!email & _
      "' WHERE Company_Code = " & Me![subforma_companie].Form!Cod

此外,您可能需要考虑某种形式的SQL Injection预防,只是让用户在DROP TABLE db.Firma_test

中输入subforma_companie form