Copy a record on a form

N

Neal

Hi there

I have a form that shows a record. I want to add a button that copies the
record, makes a new one and pastes.

I've found the easy way to do it is...

Code a Click event:

DoCmd.RunCommand acCmdSelectRecord

DoCmd.RunCommand acCmdCopy

DoCmd.RunCommand acCmdPasteAppend

This is fine on a plain form, but doesn't work on my Main/Sub form. Can
someone advise how to do this?



Thanks, Neal
 
T

Tony Vrolyk

I have never used your method but you may be able to get it to work by first
setting focus to the subform. Assuming you use a command button on the main
form try this. Focus to a subform control needs focus set to the subform
first in my experience.

Me!Subform1.Form.Setfocus
Me!Subform1.Form!ControlName.Setfocus

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

Let me know how it works

Tony Vrolyk
 
B

Brett Collings [429338]

Hmmm Neal, maybe we should take a step back for a minute.

You shouldn't be copying records, that blows Normalization and Data
Integrity out of the water.

I think I understand what you might be trying to achieve. It can be,
this just happens to be the wrong way.

Can you describe the data behind the mainform and the data behind the
subform and what you want them to do. Also useful is the Primary Key
names of the fields involved.

Brett


Hi there

I have a form that shows a record. I want to add a button that copies the
record, makes a new one and pastes.

I've found the easy way to do it is...

Code a Click event:

DoCmd.RunCommand acCmdSelectRecord

DoCmd.RunCommand acCmdCopy

DoCmd.RunCommand acCmdPasteAppend

This is fine on a plain form, but doesn't work on my Main/Sub form. Can
someone advise how to do this?



Thanks, Neal

Cheers,
Brett
 
N

Neal

Hi Brett.

Two tables. Jobs, Items. One job, many items.

We issue certificates for fire safety. On the main form is the Job details
(JobID primary key) and on the subform, all the items that have been covered
by that certificate (link - JobID).

Certificates expire, and rather than make a new record and enter all the
details all over again - and the many items in the subform, we want to
duplicate the existing record (as we see it on the main/sub form). The only
two things that would change would be the certificate number, and the JobID.

Hope this helps.

Thanks, Neal
 

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