deleting and adding records

lloydmav

Registered User.
Local time
Today, 10:02
Joined
Nov 15, 2002
Messages
75
Lets say I have two tables, table 1 and table 2.

I want to delete all the records in table 2 whose Action_Plan_ID field = "12"(12 just an example)

Then I want go to every record in Table 1 and if the Action_Plan_ID field in there = "12" I want to add all those records to Table 2.

I need to beable to do all this by the click of a button.

Can anyone give me the code for doing that

Thanks
 
Do you want to eat the Fish, or do you want to learn how to Fish? :)

Create a Delete query with criteria '12' on table2
Create an Append query with table1 appending to table2

Use the OnClick event of a command button on a form to run both queries.
 
try to help...

Hi lloydmav,

although I am no Access-programmer I can give you some hints how to solve your problem.

Create a Delete Query (=Action-query; see also MS-Access help), which deletes the records in table2 , include under Criteria of 'column' Action_Plan_ID:
="12"
or
=12
(depending on if its txt/number). When you run this query it should Delete the records of tbl 2 containing 12 for good.

Create an Amend query (=action query, too). This will amend table2 with the records of table 1 (containin 12). The criteria is the same as above.

Create a macro that runs the delete query first and then the amend query. You can link the execution of this macro to a button on a form or simply execute the macro.


HTH,
Barbarossa II


PS: pdx_man was faster than me......
 
Yeah, not the best call for help

Ok, thanks guys for the help,

I know it was a simple question but I was in a rush (1 minute before finishing work) I was getting lazy!

Thanks for the help
 

Users who are viewing this thread

Back
Top Bottom