1
似乎是sql更新查询的一个小问题。但我无法解决这个问题。不太熟悉sql。MS Access sql - 更新查询语法
基于选择,将表中选定的行(7DARphases)复制并插入到另一个表(7tblDAR)中。并且所有插入行的项目ID(PRJID列)应使用从窗体中获取的固定值(PID)更新。 问题是:我需要在添加行的PRJID列中插入固定值的部分中遇到语法问题。
代码是:
Set dbs = CurrentDb
PID = Me.PRJID.Value
sqlstr = "INSERT INTO 7tblDAR (Phase, Deliverable, Link_PIM_temp, Link_PIM_WB, Description, Accept_criteria, Deliv_type, TollgateID, Workstream, Accountable, ClientRACI) SELECT [7DARphases].Phase, [7DARphases].Deliverable, [7DARphases].Link_PIM_temp, [7DARphases].Link_PIM_WB, [7DARphases].Description, [7DARphases].Accept_criteria, [7DARphases].Deliv_type, [7DARphases].TollgateID, [7DARphases].Workstream, [7DARphases].Accountable, [7DARphases].ClientRACI FROM 7DARphases WHERE ((([7DARphases].SolType) Like '*2PP*')) ORDER BY [7DARphases].Phase, [7DARphases].Deliverable;"
sqlUpdt = "update 7tblDAR set PRJID = '" & Me.PRJID.Value & "' from 7tblDAR where tblDAR.PRJID = """""
dbs.Execute sqlstr, dbFailOnError
dbs.Execute sqlUpdt, dbFailOnError
的 'sqlstr' 工作正常,并插入行。 但“sqlUpdt”给出错误:
“运行时错误3075:语法错误(缺少操作员)在查询表达式......”
能否请你帮我出这一点。
另外,如果可能的话,您是否可以建议在一个查询本身中执行此操作。
Perfecttt解决方案Gordon ...许多非常感谢这个解决方案 –