我有一张名为{Cadets}的表格和一张名为{addCadets}的表格。
Cadets表包含以下字段:{Cdt_ID}(PK字段),{Class_ID],{L_Name},{F_Name},{Det_Email},{Phone},{Tag_ID}和{Active} [复选框/ tf flag]
我的表单是将来自5个未绑定字段的动态数据插入{L_Name},{F_Name},{Class_ID},{Det_Email}和{Phone};并在{Tag_ID}字段中插入静态Null。我正在使用的命令:
DoCmd.RunSQL "INSERT INTO Cadets ( Class_ID, L_Name, F_Name, Det_Email, Phone, Tag_ID, Active) VALUES (" & Me.Class_ID & ", " & " '" & Me.L_Name & "', " & " '" & Me.F_Name & "', " & " '" & Me.Det_Email & "', " & " '" & Me.Phone & "', " & Tag & ", " & Active & ")"
不断被标记为语法错误。即使经过仔细梳理,我和我的同事也找不到语法错误。我们正在使用Access 2001-2013,最新版本等等。表单会将所有数据正确生成到消息框中,但由于语法错误,不会将其写入表中。
答案 0 :(得分:0)
太多" &安培; "
应该是
DoCmd.RunSQL "INSERT INTO Cadets ( Class_ID, L_Name, F_Name, Det_Email, Phone, Tag_ID, Active) VALUES (" & Me.Class_ID & ", '" & Me.L_Name & "', '" & Me.F_Name & "','" & Me.Det_Email & "','" & Me.Phone & "', " & Tag & ", " & Active & ")"