Here's ADO code for a copy button I use. This is a bound form with a
listbox containing the list of addresses, with the bound column being the
primary key. Start Date is the only change required.
================================
Private Sub btnCopy_Click()
On Error GoTo handle_error
Set cnxn = CurrentProject.Connection
Set rs = New ADODB.Recordset
If IsNull(Me.lstRecords.Value) Then
MsgBox "No item selected", , "Selection Needed"
Else
With rs
.Open "address", cnxn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect
.Index = "PrimaryKey"
.Seek Me.txtId.Value, adSeekFirstEQ
If Not .EOF Then
DoCmd.RunCommand acCmdRecordsGoToNew
Me("add_off_id") = .Fields("add_off_id")
Me("add_state_id") = .Fields("add_state_id")
Me("add_residtype_id") = .Fields("add_residtype_id")
Me("add_house_no") = .Fields("add_house_no")
Me("add_apt") = .Fields("add_apt")
Me("add_street_id") = .Fields("add_street_id")
Me("add_zip_id") = .Fields("add_zip_id")
Me("add_loc_id") = .Fields("add_loc_id")
Me("add_map_id") = .Fields("add_map_id")
End If
.Close
End With
Set rs = Nothing
Me.txtStartDate.SetFocus
End If
Exit Sub
handle_error:
LogError Err.Number, "AddressForm.btnCopy", Err.Description '
Error-logging sub
End Sub
============================
You could add code that stored the old start date, and compared it to the
new start date, and did not allow a save if they were the same.
Darryl Kerkeslager
"Ray" <No**************@Yahoo.com.hk> wrote in message
news:33*************@individual.net...
I have a data input form and need to automatically duplicate the existing
record as a new record by clicking a button. The main purpose to
duplicate the record is that the new record is very similar to the existing record
with minor differences. It will save the data input operator a lot of
afford by editing the minor difference only. However, the new record is
not allowed to be saved if the operator forgets to make the modification for
whatever reasons to avoid duplicate records. Your guidance to accomplish
it is appreciated.