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!

Dim db As Database

Status
Not open for further replies.

JimCowan

Technical User
Jul 12, 2000
10
CA
I see many code examples in tek books like the following

Private Sub PayFactor_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim rst As Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("Table1")


When I attempt to run this, it gives me error code "User-defined type not defined"
The problem seems to be that "Database" is not a type. Yet everyone is using it.
I am running Office 2000 VBA. What is my solution...is this a Class property issue? and if so, what is typical code, Where should the code be placed?
 
I usually see it written as:
Private db as Database
Located in the Option Explicit area of the code
 
Make sure you have DAO object library referenced in your references. Go to tools, References, then look for Microsoft Dao Object Library ....

My 2 cents though, begin working with ADO and learn it rather than DAO.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top