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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User-defined type error

Status
Not open for further replies.

MkIIISupra

Programmer
Apr 17, 2002
108
0
0
US
I am declaring some variables for use in an application I am close to finishing and I am getting the following error:

Compile Error:
User-defined type not defined

The error is being generated from the following variable

Dim db as Database

I have another sample database I used this very same declaration / variable and no problemo. I am not sure why it's not working now.

Dim rs as Recordset is working just fine as a side note.

One by one the penguins steal my sanity!
 
You need to set a reference to the DAO object library.

In a code module, goto menu item Tools-->References and scroll down to the Microsoft DAO Object Library and check it.

Should compile fine.
 
Figured it out right after I posted. Thanks

But now I am getting a Type Mismatch error with this bit of code:

Code:
     Set rs = db.OpenRecordset("SELECT Min([startDate]) AS MinOfStartDate " _
                   & " FROM tblProject", dbOpenSnapshot)

One by one the penguins steal my sanity!
 
the database and recordset DIM statements should show "DAO" and the "DAO'reference in Tools should be checked. That is almost always the cause. ACCESS 2000 has the ADO as default handler and is looking for a conn. The DAO tells it what you want.


rollie@bwsys.net
 
I have the following selected for my References:
1 - Visual Basic For Applications
2 - Microsoft Access 9.0 Object Library
3 - Microsoft DAO 3.6 Object Library (I had 3.51 at one time earlier...)
4 - OLE Automation
5 - Microsoft ActivX Data Objects 2.1 Library
6- DirectX 8 for Visual Basic Type Library
7 - Microsoft Data Access Components Installed Version
8 - Microsoft ActiveX Data Objects Recordset 2.5 library
9 - Microsoft SQL Parser Object Library 1.0
10 - Microsoft Visual Basic for Applications Extensibility 5.3
11 - System.dll
12 - System.Windows.Forms.dll

I can't find any other referance to the DAO other than the MS DAO 3.51 Object Library and MS DAO 3.6 Object Library.

I am still getting the type mismatch on the

Code:
 Set rs = db.OpenRecordset("SELECT Min([startDate]) AS MinOfStartDate " _
                   & " FROM tblProject", dbOpenSnapshot)

One by one the penguins steal my sanity!
 
show us the DIM statements

They should be
DIM xx as dao.recordset
dim db as dao.database

rollie@bwsys.net
 
Perhaps this is obvious but sometimes they get by you

If there is a reference to the DAO library, then this will work...

dim dbs as database
dim rst as recordset
dim strSql as string

set dbs = currentdb
strSql = "SELECT Min([startDate]) AS MinOfStartDate " _
& " FROM tblProject"

set rst = dbs.openrecordset(strSql, dbopensnapshot)

yamafopa!
 
No, It will not, believe me. The program is trying to open an ADO. It must be told the objects are DAO.

Rollie E
 
Excuse me Rolliee, you are correct. I wanted to document the whole recordset instantiation process and I failed to notice that MkIIISupra's project also referenced the ADO library. Access 2000 will want to use ADO by default. So you should reference the DAO library explicitly in the Declarations - Dim dbs as DAO.Recordset.
I have read that you can change the priority of the default object reference behaviour using the References dialog box, but I have not tried it. Probably the explicit declaration is the way to go.


 
That was it! Rolliee, Thank You!

One by one the penguins steal my sanity!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top