Link to home
Start Free TrialLog in
Avatar of The_Hitcher
The_Hitcher

asked on

VBA for Access - Loop and Insert Into based on results

Morning all

I want to extract a set of records from table A (four fields - one integer, two dates and a string), and then loop through the results and insert them into table B. I'm not too sure of the best way to go about this and the syntax.

Please can someone advise.

Thanks


Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

What you have described is easily done using an append query which you can build in the query grid.
No code is required.
INSERT INTO table2
SELECT field1int, field2date, field3date, field4str FROM table1
WHERE {conditions}
ASKER CERTIFIED SOLUTION
Avatar of RCUllrich
RCUllrich
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One more thing: make sure that table2 has 4 columns:
INSERT INTO table2
SELECT field1int, field2date, field3date, field4str FROM table1
WHERE {conditions}

Open in new window

You didn't like the pure SQL solutions? Just checking.