Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allen Browne's duplicate record method giving error 1

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
330
0
0
GB
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.

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



 
I would open the debug window (in debug mode) and enter:
Code:
? Me.FinderName

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 

Ouch, thanks Duane, schoolboy error by me. I'd called the field Finder Name before creating the form, closed it, then changed the name in the table to FinderName. It was retaining the original in 'Other' name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top