duplicate record-...type mismatch

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

Guest

I have a frontend (*.adp) - backend (Sqlserver) application.
I made a command button on a form that takes the current record,
duplicates it and then displays the new identical record.
When I compile the procedure, I haven't errors, but when I click on a
command button I get message 'Type mismatch'.
I have selected reference MS DAO 3.6. Object Library.
What's wrong?
Thanks in advance, Marie


Private Sub cmd_Duplicate_Click()
On Error GoTo Err_cmd_Duplicate_Click

Dim Sifr As Long
Dim RstDup As Recordset
Sifr = Me.ID

Set RstDup = Me.RecordsetClone
DoCmd.GoToRecord , , acNewRec
RstDup.FindFirst "[ID]=" & Sifr

If Not RstDup.NoMatch Then
Me!ID_nar = RstDup!ID_nar
Me!ID_izv = RstDup!ID_izv
'etc.
RunCommand acCmdSaveRecord
End If

RstDup.Close
Set RstDup = Nothing

Exit_cmd_Duplicate_Click:
Exit Sub

Err_cmd_Duplicate_Click:
MsgBox Err.Description
Resume Exit_cmd_Duplicate_Click

End Sub
 
You cannot use DAO in an adp... u need to use the ADO Library.
And to make it more clear use ur declarations like this:
Dim RstDup As ADODB.Recordset

HTH
Sid.
I have a frontend (*.adp) - backend (Sqlserver) application.
I made a command button on a form that takes the current record,
duplicates it and then displays the new identical record.
When I compile the procedure, I haven't errors, but when I click on a
command button I get message 'Type mismatch'.
I have selected reference MS DAO 3.6. Object Library.
What's wrong?
Thanks in advance, Marie


Private Sub cmd_Duplicate_Click()
On Error GoTo Err_cmd_Duplicate_Click

Dim Sifr As Long
Dim RstDup As Recordset
Sifr = Me.ID

Set RstDup = Me.RecordsetClone
DoCmd.GoToRecord , , acNewRec
RstDup.FindFirst "[ID]=" & Sifr

If Not RstDup.NoMatch Then
Me!ID_nar = RstDup!ID_nar
Me!ID_izv = RstDup!ID_izv
'etc.
RunCommand acCmdSaveRecord
End If

RstDup.Close
Set RstDup = Nothing

Exit_cmd_Duplicate_Click:
Exit Sub

Err_cmd_Duplicate_Click:
MsgBox Err.Description
Resume Exit_cmd_Duplicate_Click

End Sub
 
Back
Top