我具有此功能:
Dim db As DAO.Database
Dim strInsert As String
Set db = CurrentDb
strInsert = "INSERT INTO items_affected_Table(CR_Id, VerOld, Equipment_Serial, Document_No, Description, Version) SELECT Items_affected_Table.CR_Id, Items_affected_Table.Version, Items_affected_Table.Equipment_Serial, Items_affected_Table.Document_No, Items_affected_Table.Description, Items_affected_Table.VerNext FROM Items_affected_Table WHERE (((Items_affected_Table.CR_Id)=[Forms]![CR form-unapproved]![CR_ID]) AND ((Items_affected_Table.Version)=[Forms]![CR form-unapproved]![Version]))"
db.Execute strInsert, dbFailOnError
它给出错误“参数太少。期望2”
如果我将表单引用更改为实际数字,则附加查询有效:
strInsert = "INSERT INTO items_affected_Table(CR_Id, VerOld, Equipment_Serial, Document_No, Description, Version) SELECT Items_affected_Table.CR_Id, Items_affected_Table.Version, Items_affected_Table.Equipment_Serial, Items_affected_Table.Document_No, Items_affected_Table.Description, Items_affected_Table.VerNext FROM Items_affected_Table WHERE (((Items_affected_Table.CR_Id)=8) AND ((Items_affected_Table.Version)=0))"
我想念什么?
谢谢
连接变量引用:
strInsert = "INSERT INTO items_affected_Table(CR_Id, VerOld, Equipment_Serial, Document_No, Description, Version) " & _
"SELECT CR_Id, Version, Equipment_Serial, Document_No, Description, VerNext " & _
"FROM Items_affected_Table " & _
"WHERE CR_Id=" & [Forms]![CR form-unapproved]![CR_ID] & " AND Version=" & [Forms]![CR form-unapproved]![Version]