"CurrentDb" not recognized

A

Alan4297

Six months ago, a VBA procedure worked fine. Now it doesn't work. The
offending line is:

Set oDbs = CurrentDb

When I run the procedure, "CurrentDb" is highlighted and the message is:

Function or interface marked as restricted, or the function uses an
Automation type not supported in Visual Basic.

What has happened?

Regards,
Alan
 
G

Gina

Hi Alan.

I had a similar problem yesterday and the days before and that's what I have
done

1. I set reference to DAO 3.6 in the vba environment
2. declared the db As DAO.DB and the recSet as DAO.Recordset

and it worked ... good luck
Gina
 
M

Marshall Barton

Alan4297 said:
Six months ago, a VBA procedure worked fine. Now it doesn't work. The
offending line is:

Set oDbs = CurrentDb

When I run the procedure, "CurrentDb" is highlighted and the message is:

Function or interface marked as restricted, or the function uses an
Automation type not supported in Visual Basic.


It sounds like you moved the program to a different machine
with different libraries. Or, maybe you created a new mdb
and copied everything from the original program.

Either way, your references are messed up. Go to any VBA
module and use Tools - References to uncheck the unneeded
ones (ActiveX...?, the 2.5 - 3.5 Compatibility ..., ADO,
???) and set the ones you do need, especially DAO.
 
W

Wayne Morgan

Gina is on the right track; however, if it worked then now doesn't it sounds
as if your references have been changed or broken. First, when declaring a
DAO object in Access 2000 or newer, specify the library in the declaration
(i.e. Dim oDbs As DAO.Database). This is because Access uses the references
in the order that the checked items are listed in the references window (in
the code editor go to Tools|References). There are up and down arrows to
change the order, but if you specify the library being used, then the order
doesn't matter. The reason for the problem is that there are objects in both
ADO and DAO with the same name, but they behave differently.

If a reference has become broken, you need to fix it. The reference that is
broken may or may not be to the library that is causing you problems, but
fixing the broken reference will usually solve the problem anyway. You will
find a good explanation of this problem here:

http://members.iinet.net.au/~allenbrowne/ser-38.html
 

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