unusual Type Mismatch error

W

Wez.k

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.
 
S

Stuart McCall

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.
 
W

Wez.k

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
 
D

Douglas J. Steele

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

Wez.k

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.
 

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