有table1 table2,table3。在table1中需要选择列Order_ID
值= 1的所有列Spec_ID
值然后,在table2 Order_ID
中选择所有Order_ID
find并将具有该ID的所有行复制到table3。
我知道如何将行插入另一个表,但我无法弄清楚如何选择多个值并使用多个值。
使用INSERT INTO声明:
insert into table3
select * from table2
where order_id in (select order_id from table1 where spec_id = 1)
仅当table2和table3具有具有相同对应数据类型的确切列数时,此方法才有效。
这不是VBA的工作,而是Append查询。
创建一个连接table1和table2的查询,具有您需要的条件,并显示您需要复制的所有列。
然后将查询更改为Append查询,并将其插入table3。
如有必要,可以使用VBA设置查询的参数,请参阅How do I use parameters in VBA in the different contexts in Microsoft Access?