0

There is table1 table2, table3. In table1 need to select all column Order_ID values where column Spec_ID values = 1 Then, all selected Order_IDfind in table2 Order_ID and copy all rows with that ID's to table3.

I know how to insert rows to other table, but I cant figure out how to select multiple values and use that multiple values.

Andre
  • 26,751
  • 7
  • 36
  • 80
Julian
  • 17
  • 4

2 Answers2

1

This is not a job for VBA, but for an Append query.

Create a query that joins table1 and table2, has the criteria you need, and shows all columns you need to copy.

Then change the query to an Append query, and have it insert into table3.

If necessary, you can set the parameter(s) for the query with VBA, see How do I use parameters in VBA in the different contexts in Microsoft Access?

Andre
  • 26,751
  • 7
  • 36
  • 80
0

With an INSERT INTO statement:

insert into table3
select * from table2 
where order_id in (select order_id from table1 where spec_id = 1)

This will work only if table2 and table3 have the exact number of columns with identical corresponding data types.

forpas
  • 160,666
  • 10
  • 38
  • 76