J
J.J.
I am using an Append Query run by a Macro which does successfuly copy the old
record over. However SetWarnings to No in the macro is not supported by
Access 2007 which creates compatiblity issues.
I tried Allen Browne's code but it is too complex for me to edit. I am still
tinkering with the following code that won't run. I hate to be a pain but I
have something wrong. Any ideas please?
Dim strSearch As String
Dim ctl As Control
' form is open with data source set to secondary table "IntakeData"
Set rst = Me.RecordsetClone
' set string value for match up where ClientID is primary key of "Client"
table linked
' to secondary table "IntakeData"
strSearch = str(Me!ClientID)
' find a match preferably the last record ( try FindLast?) that has the same
' ClientID as current form
rst.FindFirst "ClientID= " & strSearch
If rst.NoMatch Then
' There is no record match & nothing happens so tell user no cigar
MsgBox "No Previous Record Exists. Unable to Duplicate."
Else
' copy all the data over from previous record to current record
For Each ctl In Me.Controls
' need to copy all records except of course the old IntakeID
' there must be a more effcient means to copy all but the
' IntakeID besides having to tag all other fields?
If ctl.Tag = "RepeatPrevious" Then
' copy old field value to new field value
ctl.Value = .Fields(ctl.IntakeDta)
End If
Next
End If
' All records are copied now but still need code here to refresh open
form?
' this lets user add or edit before moving on
Exit_Dupli_Click: etc etc.
record over. However SetWarnings to No in the macro is not supported by
Access 2007 which creates compatiblity issues.
I tried Allen Browne's code but it is too complex for me to edit. I am still
tinkering with the following code that won't run. I hate to be a pain but I
have something wrong. Any ideas please?
Dim strSearch As String
Dim ctl As Control
' form is open with data source set to secondary table "IntakeData"
Set rst = Me.RecordsetClone
' set string value for match up where ClientID is primary key of "Client"
table linked
' to secondary table "IntakeData"
strSearch = str(Me!ClientID)
' find a match preferably the last record ( try FindLast?) that has the same
' ClientID as current form
rst.FindFirst "ClientID= " & strSearch
If rst.NoMatch Then
' There is no record match & nothing happens so tell user no cigar
MsgBox "No Previous Record Exists. Unable to Duplicate."
Else
' copy all the data over from previous record to current record
For Each ctl In Me.Controls
' need to copy all records except of course the old IntakeID
' there must be a more effcient means to copy all but the
' IntakeID besides having to tag all other fields?
If ctl.Tag = "RepeatPrevious" Then
' copy old field value to new field value
ctl.Value = .Fields(ctl.IntakeDta)
End If
Next
End If
' All records are copied now but still need code here to refresh open
form?
' this lets user add or edit before moving on
Exit_Dupli_Click: etc etc.