[英]Debugging Access VBA Currentdb.Execute
It says invalid insert statement when I run this code.当我运行此代码时,它说无效的插入语句。
CurrentDb.Execute "insert into invoices (Stateid, companyid, PaymentYear,InvoiceDate,Type,MethodofPayment,date,amount) " & _
"values('" & Me.StateID & "','cOOKIE','" & Me.PaymentYear & "', '" & Me.InvoiceDate & "'," _
& "'" & Me.Type & "','" & Me.MethodofPayment & "','" & Me.Date & "','" & Me.Amount & "');"
As a start, provide valid string expressions for the values - not everything is text - and respect reserved words:首先,为值提供有效的字符串表达式 - 并非所有内容都是文本 - 并尊重保留字:
CurrentDb.Execute "insert into invoices (Stateid, companyid, PaymentYear, InvoiceDate, [Type], MethodofPayment, [date], amount) " & _
"Values('" & Me.StateID & "','cOOKIE'," & Me.PaymentYear & ", #" & Format(Me.InvoiceDate, "yyyy\/mm\/dd") & "#, " & _
"'" & Me.Type & "','" & Me.MethodofPayment & "',#" & Format(Me.Date, "yyyy\/mm\/dd") & "#," & Str(Me.Amount) & ");"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.