error 13 mismatch type

T

TimH

when I run this code in Access vba97 there is no error; However when i run
the exact same cose in ACCESS2000 I get the run-time error of Mismach type
(error-13); does any one have an Idea as to what is wrong?
Private Sub Form_Current()

Dim recClone As Recordset
Dim intNewRecord As Integer

Set recClone = Me.RecordsetClone 'this is where the error occurs.

intNewRecord = IsNull(Me.PersonID)

If intNewRecord Then
cmdFirst.Enabled = True
cmdNext.Enabled = False
cmdPrev.Enabled = True
cmdLast.Enabled = True
cmdNew.Enabled = False
Exit Sub
End If

cmdNew.Enabled = True
If recClone.RecordCount = 0 Then
cmdFirst.Enabled = False
cmdNext.Enabled = False
cmdPrev.Enabled = False
cmdLast.Enabled = False

Else
recClone.Bookmark = Me.Bookmark

recClone.MovePrevious
cmdFirst.Enabled = Not (recClone.BOF)
cmdPrev.Enabled = Not (recClone.BOF)
recClone.MoveNext


recClone.MoveNext
cmdLast.Enabled = Not (recClone.BOF)
cmdNext.Enabled = Not (recClone.BOF)
recClone.MovePrevious
End If
recClone.Close

End Sub
 
G

George Nicholson

My guess:
Dim recClone As DAO.Recordset

The ADO object library was added after 97 and also has a Recordset object.
References need to be specific (disambiguated). Make sure you have a
reference to the DAO object library (in the VBE>Tools>References).

Although, I'm a little suprised that you get the error on that line. I would
have thought that a simple RecordsetClone could be either ADO or DAO.
<shrug>
 
D

Dirk Goldgar

George Nicholson said:
My guess:
Dim recClone As DAO.Recordset

Mine, too.
Although, I'm a little suprised that you get the error on that line. I
would have thought that a simple RecordsetClone could be either ADO or
DAO.

The recordsetclone is DAO in an .mdb file, unless it has been reassigned by
code to be an ADODB recordset. But the unqualified declaration:

Dim recClone As Recordset

would be understood as an ADODB recordset in the default installation of
Access 2000 or 2002 (hence the type mismatch error), because the ADO
reference would normally be installed before the DAO reference in the list
of references. That is, if there's a DAO reference at all. You're right
that TimH may need to add the DAO reference; I can't remember if it's
intalled by default in A2K.
 
T

TimH

Thank you; it worked:
other error now it stating : CmdFirst.enabled = true (NOT Defined)
 
T

TimH

thank you it worked
--
timH


Dirk Goldgar said:
Mine, too.


The recordsetclone is DAO in an .mdb file, unless it has been reassigned by
code to be an ADODB recordset. But the unqualified declaration:

Dim recClone As Recordset

would be understood as an ADODB recordset in the default installation of
Access 2000 or 2002 (hence the type mismatch error), because the ADO
reference would normally be installed before the DAO reference in the list
of references. That is, if there's a DAO reference at all. You're right
that TimH may need to add the DAO reference; I can't remember if it's
intalled by default in A2K.


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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