duplicate record-...type mismatch

M

marie

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
 
S

Siddharth Parekh

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top