Using Input Form - Duplicate Previous Record


S

Starwood

I am using an Input Form to create a large number of similar records. Even
though each key field is unique, the bulk of the fields in each database
record are duplicate. Is there a simple way to "duplicate the previous
record" using an Input Form in Access?

I hope this makes sense.

George L.
 
M

missinglinq via AccessMonster.com

Are you using a custom Add Record command button, or Access' native New
Record buutton?
 
Ad

Advertisements

A

Allen Browne

A simple solution might be to assign the default values from the last record
at the moment when the user starts entering a new record.

The code to do that is here:
Assign default values from the last record - Carry data over
at:
http://allenbrowne.com/ser-24.html
It's intelligent enough to assign only the desired fields (not autonumbers,
calculated fields, unbound controls, etc), and you can specify exceptions
that should not be copied.

An alternative approach is to use a command button to duplicate the record
in the form. To do this, you AddNew to the RecordsetClone of the form.
Here's the code:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
(You can ignore the part about duplicating the subform records as well.)

HTH
 
S

Starwood

Allen,

Thanks so much for your suggestions. I should be able to figure out the
"command button" approach. I think that makes the most sense, since I don't
always need to duplicate the previous record.

George L.
 
S

Starwood

Allen,

I created an event procedure using your code and a "Duplicate Record"
command button on my Input Form.

The code will not allow me to create a duplicate key field nor will it allow
me to create a record without a key field. In other words, I can't use the
code as it stands.

What I want to do is:

1) Using an Input Form, create a new record and add it to the database.
2) Issue a command on the next blank Input Form to "recall" the values of
all the fields in the previous input form.
3) Manually modify the key field and any data fields that need changing.
4) Add the new record to the database and repeat the process.

Is there any way to have the code "recall and display" the previous field
values in the Input Form, but not try to add it to the database until I make
the necessary field changes.

George L.
 
A

Allen Browne

Yes: work the other way around.

FindFirst the current record in the form's RecordsetClone.
Move the form to a new record, i.e. RunCommand acCmdRecordsGotoNew
Then copy the field from the clone set to the form, e.g.:
Me.SomeField = rs!SomeField
etc.
 
Ad

Advertisements

S

Starwood

Thanks, I'll give it a try.

George L.

Allen Browne said:
Yes: work the other way around.

FindFirst the current record in the form's RecordsetClone.
Move the form to a new record, i.e. RunCommand acCmdRecordsGotoNew
Then copy the field from the clone set to the form, e.g.:
Me.SomeField = rs!SomeField
etc.
 

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