best way to copy a record?

J

Jerome

Hi,

(using MS Access 2000)

I've got a form (containing subforms) displaying data related to the
record. Now I want to copy the data from the main form (not the
subforms) into a new record (in the same table) and then move to that
record to edit the copy.

What's the best way to do that? I imagine doing it by code? But could
somebody please give me an example. I tried looking on the internet, but
haven't found anything really helpful.

Any help is greatly appreciated!

Jerome
 
D

Dirk Goldgar

Jerome said:
Hi,

(using MS Access 2000)

I've got a form (containing subforms) displaying data related to the
record. Now I want to copy the data from the main form (not the
subforms) into a new record (in the same table) and then move to that
record to edit the copy.

What's the best way to do that? I imagine doing it by code? But could
somebody please give me an example. I tried looking on the internet,
but haven't found anything really helpful.

Any help is greatly appreciated!

Jerome

The command button wizard will create a button with the necessary code
to do this. However, the code generated by the wizard is rather obscure
and out of date. The following sequence of statements will do the same
thing:

RunCommand acCmdSelectRecord
RunCommand acCmdCopy
RunCommand acCmdPasteAppend

Note that this will cause a confirmation prompt to be displayed, unless
you have them turned off in your options settings. You can disable that
prompt temporarily with the DoCmd.SetWarnings method:

DoCmd.SetWarnings False
RunCommand acCmdSelectRecord
RunCommand acCmdCopy
RunCommand acCmdPasteAppend
DoCmd.SetWarnings True

If you do that, though, you should also set up error-handling in your
code to ensure that there is no way the routine can exit without turning
warnings back on.
 
N

neenmarie

When copying and appending in this way,
RunCommand acCmdSelectRecord
RunCommand acCmdCopy
RunCommand acCmdPasteAppend

is there a way to append this to a different table?
I want to copy and append a record to another table before I allow the user
to delete the record so I can track what has been deleted from the table.
 
V

Van T. Dinh

You can use an Append Query or "INSERT INTO ..." SQL construct.

See Access Help on the above.

--
HTH
Van T. Dinh
MVP (Access)
 
N

neenmarie

I have a form with a continuous subform to search for a transaction and
secondary transactions created from the first transaction through an append
query which includes calculations depending on the type of transaction
(receiving of raw material or receiving of outside processed material). The
raw material transaction will only create inventoy. While the outside
process transaction will relieve inventory from the outside location and
create it in house.

This form is used to correct receiving errors, so I need to correct errors
created in the secondary, append transactions. I would, however, like to
have an audit trail of changes or deletions made. So, I'm looking for a way
to add scrip to each field on the form so it will append to the audit table
if changed...or to a delete button if deleting the entire record.

Can I use
And just add something here to tell it to insert into the audit table or
append to the audit table?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top