
ACC2000:Run Time Error '13': Type Mismatch
Quote:
>Why am I getting the error "Run Time Error '13': Type Mismatch", in Access
>2000 when I hit the dbs.OpenRecordset line? Sample code is below:
>Dim dbs As Database, rst As Recordset
>Dim strSQL As String
>' Return reference to current database.
>Set dbs = CurrentDb
>strSQL = "BackupCRP_F47047"
>Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
>rst.MoveLast
>Debug.Print rst.RecordCount
>rst.Close
>Set dbs = Nothing
Tony
As you are running A2k, you must have DAO 3.6 referenced (otherwise it would
fail on the line 'Dim dbs As Database'), but you probably also have ADO still
referenced. A Recordset Object appears in both ADO and DAO Object libraries,
with different properties, and you must disambiguate any such object so that
the correct one is used (otherwise Access uses the order of references).
Therefore:
Dim rsDAO As DAO.Recordset
Dim rsADO As ADODB.Recordset
Jon
Access tips & tricks - http://www.applecore99.com
Microsoft Access webring -
http://nav.webring.yahoo.com/hub?ring=microsoftaccess