Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to define QueryDef object? 1

Status
Not open for further replies.

sjh

Programmer
Oct 29, 2001
263
US
Hi, I have the following line in my VBA code.

Dim qdf As QueryDef

When I try to compile it, I get "User-defined type not defined" compile error on the above line.

Any ideas??? Do I need to add something to my access database?

Thank you in advance~
SJH
 
You may need to set a reference to the Microsoft DAO library. Do this in a module by selecting Tools|References and checking the library. Your code should be changed to:
Dim qdf as DAO.QueryDef

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Thank you Duane for your help! I added the reference and I no longer get the "User-defined type not defined" error.

Now, when I try to run the following code, I get the "Run time error 13, Type mismatch" message on the last line.

Dim rs As Recordset
Dim qdf As QueryDef

Set qdf = CurrentDb.QueryDefs("MyQuery")
qdf.Parameters("Project ID") = strProjID
Set rs = qdf.OpenRecordset()

Please help!
SJH
 
Might be because you didn't understand my suggestion with explicitly using DAO in your dim statements.
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top