Copy record in to the same table

B

bermetj

I have a form that pulls a list of Investigators from a Table (PI
Table), from which you can select a record and by clicking on (Edit
Record) button open another form and see details for this record. I am
trying to ease data entry and would like to make a (Copy) button that
would pull the selected record from (PI Table) and add it to the same
table as a new record leaving some fields blank. Thank you!
 
J

John Vinson

I have a form that pulls a list of Investigators from a Table (PI
Table), from which you can select a record and by clicking on (Edit
Record) button open another form and see details for this record. I am
trying to ease data entry and would like to make a (Copy) button that
would pull the selected record from (PI Table) and add it to the same
table as a new record leaving some fields blank. Thank you!

Have the button run an Append query from the table to itself, using
the primary key field from the form as a criterion.

John W. Vinson[MVP]
 
B

bermetj

John said:
Have the button run an Append query from the table to itself, using
the primary key field from the form as a criterion.

John W. Vinson[MVP]

It gives me a validation rule error. Some fileds that I would like to
leave blank while copying are required. Is there a way to copy the
selected record into a memory, populate the fields into the form and
then save it as a new record?
 
J

John Vinson

It gives me a validation rule error. Some fileds that I would like to
leave blank while copying are required. Is there a way to copy the
selected record into a memory, populate the fields into the form and
then save it as a new record?

Sure, bit it's a bit more work. You'll need to copy each control's
value into a variable, move to the new record, and copy back into the
controls:

Dim vThis As Variant, vThat As Variant, vTheOther As Variant
vThis = Me!txtThis
vThat = Me!txtThat
vTheOther = Me!cboTheOther
DoCmd.GoToRecord acForm, Me.Name, acNewRecord
Me!txtThis = vThis
Me!txtThat = vThat
Me!cboTheOther = vTheOther


John W. Vinson[MVP]
 
B

bermetj

John said:
Sure, bit it's a bit more work. You'll need to copy each control's
value into a variable, move to the new record, and copy back into the
controls:

Dim vThis As Variant, vThat As Variant, vTheOther As Variant
vThis = Me!txtThis
vThat = Me!txtThat
vTheOther = Me!cboTheOther
DoCmd.GoToRecord acForm, Me.Name, acNewRecord
Me!txtThis = vThis
Me!txtThat = vThat
Me!cboTheOther = vTheOther


John W. Vinson[MVP]

Thank you!
 

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