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

User defined Object Error 1

Status
Not open for further replies.

RussOSU

Technical User
Apr 16, 2001
93
US
I am working on a database application menu and I am using a recordset to grab some information from the switchboard items table that Access creates. When dimensioning my variables I am getting an error that says User Defined Type not defined. and the error says it is coming from my line

Dim objDB As Database

I am using access xp. I am confused because I have created other apps that this error did not occur on and work fine. Is this something new from Access 2000 to Access XP?

Russ
 
Access 2000 and up use ADO as the default data access model. Prior versions use DAO. Dim db as Database is a DAO command. To use it and other DAO commands, you have to add the Microsoft DAO 3.6 library by going to Tools/References from the VBA editor, and select the library from the pull down menu. You should also use the prefix DAO, e.g.
Dim db as DAO.database
before all DAO objects.
 
Thank you very much. That fixed it

Russ
 
I have another question sorry. Is it possible to Dim a variable as a string and then use it in a recordset? Ex.

Dim objRS as Recordset
Dim strSQL as String

strSQL = SQL Statement

Set objRS = objDB.OpenRecordset(strSQL)

The reason I am asking is that I get a type mismatch error in my open recordset statement.

Russ
 
Change
Dim objRS as Recordset
to
Dim objRS as DAO.Recordset
the ADO recordset is the default and is a completely differnt animal
 
So since I am used to programming and using DAO objects I need to put the DAO. infront of ALL the objects I use in order to make sure that I don't have any problems like these?

Thank you for ALL your help

Russ
 
Correct. Your using a technology that is slated for the scrap heap, so they want to make it hard for you. ADO is not that hard to learn. WROX has a great series of Beginning ADO books.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top