I'm trying to use Allen Browne's code to duplicate some of a form's fields in a new record, as below for just one duplicate. Acknowledging that he's a master of his trade it must be something I'm doing wrong.
I get a Compile Error 'Method or data member not found, pointing at FinderName. This is a bona fide field on the form, so not clear to me what the problem is.
In case it's to do with References these are the ones set.
Visual Basic For Applications
Microsoft Access 15.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Code:
Private Sub cboAddBatch_Click()
On Error GoTo Err_Handler
'Purpose: Duplicate the main form record and related records in the subform.
Dim strSql As String 'SQL statement.
Dim lngID As Long 'Primary key value of the new record.
'Save any edits first
If Me.Dirty Then
Me.Dirty = False
End If
'Make sure there is a record to duplicate.
If Me.NewRecord Then
MsgBox "Select the record to duplicate."
Else
'Duplicate the main record: add to form's clone.
With Me.RecordsetClone
.AddNew
!FinderName = Me.FinderName
.Update
Me.Bookmark = .LastModified
End With
End If
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, , "cmdDupe_Click"
Resume Exit_Handler
End Sub
I get a Compile Error 'Method or data member not found, pointing at FinderName. This is a bona fide field on the form, so not clear to me what the problem is.
In case it's to do with References these are the ones set.
Visual Basic For Applications
Microsoft Access 15.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library