|
Home > Archive > MS Access project with SQL Server > April 2005 > duplicate record-...type mismatch
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
duplicate record-...type mismatch
|
|
| marie@ann.com 2005-04-29, 7:26 am |
| 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_Cl
ick
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_C
lick:
Exit Sub
Err_cmd_Duplicate_Cl
ick:
MsgBox Err.Description
Resume Exit_cmd_Duplicate_C
lick
End Sub
--
marie
| |
| Siddharth Parekh 2005-04-29, 9:26 am |
| 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.
[color=darkred]
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_Cl
ick
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_C
lick:
Exit Sub
Err_cmd_Duplicate_Cl
ick:
MsgBox Err.Description
Resume Exit_cmd_Duplicate_C
lick
End Sub
--
marie
| |
| Sylvain Lafontaine 2005-04-29, 11:26 am |
| Like Jacko, ADP are a mix of DAO and ADO. You can bind a DAO recordset to a
form (http://support.microsoft.com/?kbid=281998 ) but by default, ADP create
ADO recordset and you cannot retrieve a DAO recordset if it's an ADO
recordset which has been created in the first place.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
"marie@ann.com" < marieanncom@discussi
ons.microsoft.com> wrote in message
news:C59CB985-3EAD-433A-AD16- 8EFFDC0E12D3@microso
ft.com...
>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_Cl
ick
>
> 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_C
lick:
> Exit Sub
>
> Err_cmd_Duplicate_Cl
ick:
> MsgBox Err.Description
> Resume Exit_cmd_Duplicate_C
lick
>
> End Sub
> --
> marie
|
|
|
|
|