对于初学者来说,我几乎对VBA代码一无所知。我在这里尝试做的是从表单和子表单中获取信息,并将其作为新记录输入到设置为子表单记录源的表中。
错误代码为:运行时错误'3075':
查询表达式'GENERAL METAL (CUBEX)‘中存在语法错误(缺少运算符)。
我也为它的凌乱而道歉。老实说,我只是试图复制我在YouTube视频中看到的东西,这在某种程度上代表了我试图做的事情。
CurrentDb.Execute "INSERT INTO workingorders(customer, partname, partnumber, metal, grade, unitweight, Process, subcontract, MoldDescription, moldlocation, specialconcerns, shippinginst, datereq, orderdate, qtyordered, qtycast) " & _
" VALUES(" & Me.customer & ", '" & Me.partname & "','" & Me.partnumber & "','" & Me.metal & "','" & Me.grade & "','" & Me.unitweight & "','" & Me.Process & "','" & Me.subcontract & "','" & Me.MoldDescription & "','" & Me.moldlocation & _
Me.specialconcerns & "','" & Me.shippinginst & "','" & Me.datereq & "','" & Me.orderdate & "','" & Me.qtyordered & "','" & Me.qtycast & "')"发布于 2013-07-13 02:04:47
这部分与我有关:'“& Me.moldlocation &_ Me.specialconcerns & "'
看起来您缺少行取消之前的右引号。任何时候你看到"& _“,它都是在告诉代码你正在移到一个新行,但是在代码运行时要抑制那个换行符。在此之前,您通常需要结束引号,就像在另一行suppressor:qtycast)“&_”值()中所做的那样
所以,简而言之,试一试:
CurrentDb.Execute "INSERT INTO workingorders(customer, partname, partnumber, metal, grade, unitweight, Process, subcontract, MoldDescription, moldlocation, specialconcerns, shippinginst, datereq, orderdate, qtyordered, qtycast) " & _
" VALUES(" & Me.customer & ", '" & Me.partname & "','" & Me.partnumber & "','" & Me.metal & "','" & Me.grade & "','" & Me.unitweight & "','" & Me.Process & "','" & Me.subcontract & "','" & Me.MoldDescription & "','" & Me.moldlocation "'," & _
"'" & Me.specialconcerns & "','" & Me.shippinginst & "','" & Me.datereq & "','" & Me.orderdate & "','" & Me.qtyordered & "','" & Me.qtycast & "')"由于我不知道您的数据,我只想提醒您,任何文本都需要用单引号括起来(即'“& Me.grade & "',),而任何INT类型的数据都不需要单引号(即”& Me.customer &“)。只需确保所有变量都相应地包含在内,否则也会导致错误。
如果这回答了您的问题,请不要忘记给答案打上复选标记。谢谢!
https://stackoverflow.com/questions/17620331
复制相似问题