We help IT Professionals succeed at work.
Get Started

Using VB in MS Access to Insert Multiple Rows from a Query into a Table

545 Views
Last Modified: 2021-04-21
I need to be able to insert muliple rows returned by a query into a seperate table, using VB code.

ie, when I click a button, it executes the query in the background. The query returns somewhere between 2 - 10 lines, each of which need to be inserted into a seperate table.

I have tried using DoCmd.RunSQL and Insert Into, but I can't seem to get it to work. (I assume I can only insert one row at a time using this.)

I was thinking about executing my query into a 2D array, then inserting each line into the database one at a time, but I wonder if there isn't an easier way.

Any ideas?
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE