user defined type not defined

L

leon

I have written the undermentioned function but it won't work and i do
not know why . it returns the following error:

user defined type not defined

and it highlights the line: Dim db as database.

does anybody know what is wrong??


Public Function test()


Dim db As Database
Dim rs As Recordset
Dim strSQL As String
strSQL = "Select * from tbl_ic_matchers"

Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL)








End Function
 
T

Ted Allen

Hi Leon,

Check your references (Tools|References from the code
window) to make sure you have a reference to DAO. Also,
if you have a reference to ADO, you should explicitly
define your recordset as DAO.Recordset, and you can
define the database in the same manner(DAO.Database),
although I don't think that the database object is
repeated in ADO.

In any case, I think that it is a good habit in general
to explicitly define these object variables so that
Access doesn't have to search the other object libraries
for them.

HTH, Ted Allen
 
D

Duane Hookom

Select Tools|References and make sure you have the Microsoft DAO library
checked. Then write code like:
Dim db as DAO.Database
Dim rs as DAO.Recordset
 

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