New button to clone last record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there an easy way to do the following:

I want the action of a new command button to be the same as the new record
button except all controls will be pre-populated with the data from the last
record added (which will be the last in the recordset). Is there an easy way
to do this without opening a recordset or populating each control
individually? Thanks.
 
The last record added may or may not be the last record in the recordset.
Also, if this is a multi user environment, it could be a record another user
added.

Are you asking that when you click the new command button, it will replicate
the current record? If so, an easy way to do this would be to create a
variable for each control on your form in the Click event of the button and
when the button is clicked, assign the value of each control to its
corresponding varialbe. Then go to a new record and assign the value of each
variable to its corresponding control.

Now, if it is rather the actual last record in the recordset, you can do
almost the same thing. It just takes a couple of extra steps.

Since we will be moving in the recordset, I would suggest you turn Echo off
so the user wont see the screen jump around. Then, go to the last record of
the recordset, do the same routine of copying the controls to variables, go
to a new record, populate the controls from the variables, then turn Echo
back on. Without actually testing this, I don't know if there is anything I
am missing. One thing that may be needed is to do a repaint after you turn
Echo back on.

Hope this works for you, let me know.
 
Back
Top