简体   繁体   English

调试访问 VBA Currentdb.Execute

[英]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.

相关问题 在Excel / VBA中执行Currentdb.execute执行时出现问题 - Issue executing Currentdb.execute in Excel / VBA CurrentDb.Execute 删除查询从 VBA 执行时不删除任​​何内容 - CurrentDb.Execute delete query not deleting anything when its executed from VBA 我可以从 MS Access 运行 CurrentDb.Execute 并在其中使用 SQL Server 查询吗? - Can I run CurrentDb.Execute from MS Access with an SQL Server Query in it? Access 2016 DoCmd.RunSQL & CurrentDb.Execute 不适用于更新查询 - Access 2016 DoCmd.RunSQL & CurrentDb.Execute are not working for update queries Currentdb.Execute(Database.Execute)无法正常工作或抛出错误 - Currentdb.Execute (Database.Execute) not working or throwing errors CurrentDb.Execute 错误 3061 和 DAO.Recordset 错误 - CurrentDb.Execute Error 3061 and DAO.Recordset Error 将 dbFailOnError 添加到 CurrentDb.Execute 无法更新表 - Adding dbFailOnError to CurrentDb.Execute fails to update table DoCmd.SetWarnings和CurrentDB.Execute之间有什么区别 - What's the difference between DoCmd.SetWarnings and CurrentDB.Execute 插入语句不适用于 MS Access VBA 中的 CurrentDB 执行 - Insert statement not working with CurrentDB Execute in MS Access VBA 尽管SQL字符串在查询生成器中正常运行,但使用CurrentDb.Execute(sqlStr)时出错 - Error using CurrentDb.Execute(sqlStr) despite SQL string functioning properly in query builder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM