VBA for Access

  • Thread starter Thread starter danielmeehan
  • Start date Start date
D

danielmeehan

I am using Access 2003. I have a form created and I want to add a
button that will: 1)copy a record from tableA, 2)Delete that record
from tableA, 3)Paste that same record in tableB. I'm assuming the best
way to do this would be using a VBA module, but I'm not sure how to get
started. Any help would be much appreciated. I don't have much
practical experience with VBA, but I understand the concepts.
 
Daniel,
You can just create the queries you need to do what you wnat, and
call/run them from the module.
1) + 3) Can both be done with one Append query from TableA to TableB
2) Can be done with a Delete query against TableA.
 
the easiest way: write a Select query to pull the specific record you want
from tableA. then turn the Select query into an Append query to append the
record to tableB. make a copy of the query, and turn the copy into a Delete
query to delete the record from tableA. use a macro or VBA to run two
OpenQuery actions, first on the Append query and then on the Delete query.
in the macro precede the OpenQuery actions with a SetWarnings action to turn
warnings Off. in a VBA procedure, run a SetWarnings action *both before and
after* the OpenQuery actions, to turn warnings off and then back on again.

hth
 
Back
Top