Keep having to compact/repair - what's going on?

M

M Skabialka

I have a new database which keeps having errors on code that works
elsewhere.

First it was
Set rs = db.OpenRecordset("tblDocument")
Run-time error '13': Type Mismatch

then
rs.FindFirst "[IDNum] =" & RecID
Error 3251 Operation is not supported for this type of object

Each time I did a compact/repair and the code started working again.

I even imported everything into another new blank database.
What could be causing this? And how do I fix it?

Thanks,
Mich
 
S

Sylvain Lafontaine

Maybe a mix between DAO and ADODB data types. Try writing the full data
type of your objects:

Dim rs as DAO.Recordset
or:
Dim rs as ADODB.Recordset

Check the references in the VBA window and make sure that « Microsoft DAO
3.6 Object Library » and « Microsoft ActiveX Data Objects 2.7 Library » are
in the correct order for you.
 
M

M Skabialka

I am using Dim rs as DAO.Recordset

What on earth is the correct order for references? I though you just had to
have the right ones checked!

They are in this database, in this order
Visual Basic for Applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library

Why would the order make any difference, and cause me to have to
compact/repair whenever the code stops working?
Mich

Sylvain Lafontaine said:
Maybe a mix between DAO and ADODB data types. Try writing the full data
type of your objects:

Dim rs as DAO.Recordset
or:
Dim rs as ADODB.Recordset

Check the references in the VBA window and make sure that « Microsoft DAO
3.6 Object Library » and « Microsoft ActiveX Data Objects 2.7 Library »
are in the correct order for you.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC


M Skabialka said:
I have a new database which keeps having errors on code that works
elsewhere.

First it was
Set rs = db.OpenRecordset("tblDocument")
Run-time error '13': Type Mismatch

then
rs.FindFirst "[IDNum] =" & RecID
Error 3251 Operation is not supported for this type of object

Each time I did a compact/repair and the code started working again.

I even imported everything into another new blank database.
What could be causing this? And how do I fix it?

Thanks,
Mich
 

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