unusual Type Mismatch error

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

Guest

Hello

A piece of code that has been working OK for some time has suddenly fallen
over with a Type Mismatch error. The line in question is :

Set rs = CurrentDb.OpenRecordset(strTableName, dbOpenDynaset)

I resolved the issue by removing the "Dim rs as Recordset" declaration and
everything has now gone back to normal, but I would be grateful if anyone
could throw any light on why this may have happened?

Regards.
 
Wez.k said:
Hello

A piece of code that has been working OK for some time has suddenly fallen
over with a Type Mismatch error. The line in question is :

Set rs = CurrentDb.OpenRecordset(strTableName, dbOpenDynaset)

I resolved the issue by removing the "Dim rs as Recordset" declaration and
everything has now gone back to normal, but I would be grateful if anyone
could throw any light on why this may have happened?

Regards.

Try Dim rs As DAO.Recordset. If that works then I suspect you have a
reference to ADO. Either remove said reference, or move your DAO reference
so it is listed before ADO. Better still, use disambiguation in all your
declarations:

Dim db As DAO.Database
Dim qdf As DAO.QueryDef

etc.
 
Thanks for your reply Stuart

I have checked my references and I have no ADO refs, but I do have the
'Microsoft DAO 3.6 Object Library'

However, I have tried your suggestion of 'Dim rs As DAO.Recordset' and it
does seem to have done the trick, thanks.

Regards
 
The ADO reference is named Microsoft ActiveX Data Objects 2.n Library (where
n will range from 0 to 8)
 
Thanks Douglas

I've looked again at my references and sure enough there it is...

Microsoft ActiveX Data Objects 2.1 Library

I'll try and remember that one, thanks again.
 
Back
Top