Copying Information

dkbrostyle

New Member
Joined
Mar 16, 2002
Messages
28
Hi my problem at the moment is that, within my database i have created a search query, so a search is made then the details are displayed. What i want to do now is create a macro or fuction in which after a search is made and the details are presented in a form view is to have a button which is clicked and what has been searched for is then copied to another table.

My problem here is that i know that an append query has to be used but i don't know how to design it, so it would be like after a search is made, a command button would be press which would run the append query.

Thank-you for your help and time.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi dkbrostyle

An append query is written like so :

Code:
INSERT INTO <TargetTableNameHere>
SELECT <FieldNamesHere> FROM <DataTableNameHere> WHERE...

You can use any valid SELECT statement, including joins, Group By or even references to other queries etc.

In your case you could run a query against Table A and Table B and that returns records not in the table A, and then Insert the new data into table A, like so:

Code:
INSERT INTO TableA
SELECT Value1, Value2, value3, value4 FROM TableA
RIGHT OUTER JOIN TableB ON TableA.value1 = TableB.value1;

assuming value1 is a value in TableB that is not in TableA, yet. In a Right Outer Join, all unmatched records from the table on the right (of the ON statement) are preserved.

Try that

anvil19
:eek:
 
Upvote 0

Forum statistics

Threads
1,221,680
Messages
6,161,248
Members
451,692
Latest member
jmaskin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top