Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving records

Status
Not open for further replies.

99mel

Programmer
Oct 18, 1999
379
GB
Whats the function to move a record to from an existing table to another table??<br>
The nearest the help says to this is by moving the position in a recordset.<br>
All i'm looking to do is have a button on a form which is displaying a specific record and when this button is pressed the data in that record is moved to another table.<br>
<br>
Thanks in advance
 
Why not just create two queries? One to append the current data to the other table, and the other to delete the data from the current table.<br>
<br>
A move is really just a copy and delete.<br>
<br>
Set it off like this:<br>
<br>
Sub button_Click()<br>
DoCmd OpenQuery "AppendQueryName"<br>
DoCmd OpenQuery "DeleteQueryName"<br>
End Sub<br>
<br>
You'll need to either shut off confirm in options, or use Sendkeys to answer Yes e.g. Sendkeys "(%y)"<br>
<br>
Good luck!
 
You might want to consider using the RUNSQL method of DoCmd to do the above. This will save you creating two query objects.<br><br>For example:<br><br>DoCmd.RunSQL "INSERT INTO ...."<br><br>DoCmd.RunSQL "DELETE FROM ...."<br><br>WP
 
To shut off the confirm request, put<br>
<br>
Docmd.setwarnings false<br>
<br>
before you run the append and delete queries and<br>
<br>
Docmd.sewarnings true<br>
<br>
after you run them.
 
don't forget the &quot;t&quot; in the Setwarnings <br>
Docmd.sewarnings true &lt;--------Typo in 4th line<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top