copying records via command button

  • Thread starter Thread starter Jim VanGordon
  • Start date Start date
J

Jim VanGordon

I'm trying to figure out a way to cut a single record out
of a table and paste it into another table via a command
button on the form. I've got the code to duplicate a
record that Access gave me but I don't know where to go
from here.

Here's what I've got but I don't know if I would need to
alter this or just start from scratch.

Private Sub Copy_Record_Click()
On Error GoTo Err_Copy_Record_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, ,
acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, ,
acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, ,
acMenuVer70 'Paste Append

Exit_Copy_Record_Click:
Exit Sub

Err_Copy_Record_Click:
MsgBox Err.Description
Resume Exit_Copy_Record_Click

End Sub

Thanks,
Jim VanGordon
 
Private Sub Copy_Record_Click()
Dim dbs as datbase
set dbs = currentdb
dbs.execute ("INSERT INTO table2 SELECT table1.* FROM
table1 WHERE table1.criteria ='" & "this record" & "'")
End Sub

This only works if the criteria you are looking for is a
string value. If you criteria is a number value, use this:

dbs.execute ("INSERT INTO table2 SELECT table1.* FROM
table1 WHERE table1.criteria =" & criteria)
 
That code looks fine but it won't let me declare a
variable as a database. Now what?

-Jim VanGordon
 
Back
Top