Insert Into Code会引发错误

时间:2013-12-23 14:52:16

标签: ms-access access-vba

我正在使用此代码将4个文本框插入表中。

CurrentDb.Execute = "INSERT INTO tbl_machineheader(Line No, Description, Service Interval, Type) values ( '" & Me.Combo3 & "', '" & Me.Text1 & "', '" & Me.Text6 & "', '" & Me.Text12 & "')"

然而它似乎不起作用,我无法弄清楚为什么。

1 个答案:

答案 0 :(得分:1)

那个“=”字符错了:

CurrentDb.Execute **=** "INSERT INTO tbl_machineheader(Line No, Description, Service Interval, Type) values ( '" & Me.Combo3 & "', '" & Me.Text1 & "', '" & Me.Text6 & "', '" & Me.Text12 & "')"

此外,您应该使用方括号作为列名。正确的语法如下:

CurrentDb.Execute "INSERT INTO tbl_machineheader([Line No], [Description], [Service Interval], [Type]) values ( '" & Me.Combo3 & "', '" & Me.Text1 & "', '" & Me.Text6 & "', '" & Me.Text12 & "')"