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

Thoroughly Confused

Status
Not open for further replies.

Tim2

Programmer
Jan 10, 2002
3
US
Hello, I'm new to this forum and only slightly newer to VB. Actually, I'm using VBA for Access. My objective is to write a little table cleanup utility that will remove values from certain records while leaving the rest of the record values intact.
I have several books, the help screens and the Northwind db to help me figure out and work out techniques.

I seem, however, to have a FUNDAMENTAL problem that books, etc. aren't helping me with: I open a standard module in one of my databases and write the following simple code that I've copied directly from Northwind, except for changing the names of the table and the field.

Public Sub LoopRecordset()
Dim db As Database, rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("Kitsap", dbOpenTable)
Do Until rst.EOF
Debug.Print rst!Buildings
rst.MoveNext
Loop
End Sub

The problems are:

When I attempt to dimension the database and recordset variables, the drop down menu with the Dim statement does not contain a "database" line. It does include a recordset line. I gather that this problem causes my second problem.

When I attempt to run this code with MY database (neither of these problems occur in Northwind) I get the following message:

compile: error user-defined type not defined

The Dim db as database statement is highlighted in blue and the yellow highlight is on the first line.

I (think I) read that modules and procedures have some kind of context in which the Dim statements, etc. only display the objects that are applicable to that module/procedure, but I'm just not getting what the difference between this same code does in Northwind and my database.

Just, FYI, and also a little perplexing to me, is that the DoCmd.OpenTable works just fine.

Thanks for your help; I hope someday I won't be quite so behind the 8 ball!

Tim Rood
 
Check your references. Make sure you have the Microsoft DAO 3.51 Object Library selected.

Paul
 
The problem is definately the references ... Check Tools->References and check Microsoft DAO. When you type Dim db as database, after you type the as the vb autocomplete should pop database right up there after you type a few characters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top