Dim db as Database

beware1

New member
Local time
Today, 19:03
Joined
Jun 26, 2003
Messages
7
Hello, I'm going mad, a usuall action cause error:

Sub
Dim db as Database
dim lp as Recordset

set db=CurrentDb
set lp=db.OpenRecordsourse("SomeTable")

With lp
...
end with

close lp

end Sub


All this perfectly worked in all my previous Access projects, but now it doesn't and cause a error User-defined type not defined (in the following string "dim db as database"). If I try to enter listing again the autofill doesn't show type Database. But at the same time old files still work without any errors. What's the problem.
Please say that I'm wrong somewhere or I will crush this damn computer.
Thanks.
 
What is more interesting, if i take my previous *.mdb files where all this work, delete everything from them and paste my new tables and forms, no errors occur.
 
It's a simple and common problem. You don't have a reference to DAO.

Open a module, then goto Tools -> References

Select Microsoft Data Access Objects 3.6 library

Move its priority above Microsoft ActiveX Data Objects

Now, that's it.


The only thing I'll add is that your code is ambiguous with respect to its data access method.

Since you are using DAO it is a better practive to explicity state that.

Code:
Dim db as DAO.Database 
Dim lp as DAO.Recordset
 

Users who are viewing this thread

Back
Top Bottom