Copying a record within the same table

  • Thread starter Thread starter jp
  • Start date Start date
J

jp

hello,

(appologize if this have been covered before, but my search has not
resulted in an answer)

I need to copy a record within the same table. I've tried the following:

INSERT INTO Table1 AS SELECT * FROM Table1 WHERE ID=xxx

I will get the comment: "You are about to append 1 row(1)" which is a good
sign. Replying Yes to this results into:

"Database can't append all the records in the append query
...... and it didn't add 1 record(s) to the table due to key violations
......"

I suspect that the problem comes from the ID field which is an Autonumber
field. Is there a way to get around this?

An alternative would be to copy one field at a time (or create a code that
would copy the fields to an array and copy from the array to the table) but
it would be much easier to use the INSERT INTO statement.

Any other suggestions??
 
It was actually answered a few topics earlier; I can use the following in
my code

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.Runcommand acCmdPasteAppend

Now I just have to find a way to copy a record in a subform....

jp
 
Try listing the nonviolating fields in the SQL

INSERT INTO Table1 AS SELECT Name,Address,City FROM Table1
WHERE ID=xxx
 
Back
Top