Duplicating several fields with 1 click

Julie123

New member
Local time
Today, 16:48
Joined
Jul 6, 2006
Messages
6
Hi

I need to be able to copy 5/6 fields from one record to the next then carrying on entering different data, ie copy date, location, time then enter name address etc.

I can copy the whole record but not just a couple of fields

Any ideas?

I am using access 2000.

Thanks
 
Hi
Best way might be to copy the fields you want to variables then use the same variables to populate the next record.
Sort of strClientName = Me.txtClientName to copy then when you move to the next record you reverse using Me.txtClientName = strClientName
I think this would do the trick. May be more elegant ways though!
Good luck
 
Why not use wizard to create command button that will do a "Duplicate Record" and see what code it uses. I can't remember if the code for this particular situation is obsolete, though.
 
I'm not sure how the article KB88670 is better than setting several fields' default value.... :confused:
 
Is it always the previous record that you want to copy from?

You should be able to make the code in the sample suit your form.

If you want to "Duplicate" a selected record then post back.
 

Attachments

Ability to copy but not default

If you didn't want that as the default, but rather wanted the ability to copy selected fields from previous record when necessary, would you put the code from the above example in a "Copy" button instead?
 
WrHn85,

Short answer is No.


If you want to copy a selected record then have a look at the attached sample;
 

Attachments

Wow - that does it nicely. Thanks again, John!
 
The solution I found was to take the fields you need over and over again and put AfterUpdate code that makes sets the DefaultValue to the entered value, then turns the tab stop off. All fields are required, so they can't miss any. Then, when they enter the one field that will change, and tab forward, all the values in the other fields stay until they close the form. I put OnOpen code on the form that takes it to a new record. That seemed to work to make it so the fields were blank the next time I opened the form (they didn't hold the default from the previous record when the form was opened the last time).
 
Ansentry: At work, I was asked to develop the feature of copying data from any record into a new record. Your solution and test database will really speed this development. Thanks.
 
Ghudson: I just finished the project and I came to check the forum again. I was amused by your discussion on "NULL" values since it was so true. I had to do quite a bit of data validation as a precursor to adding the data to the new record and one of the stumbling blocks was the "NULL" value. Basically, I tested for the "NULL" and zero length string situations and if true entered "Data Not Available" into the textbox. All is well, thanks for the help.
 

Users who are viewing this thread

Back
Top Bottom