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

simple error.......giant headache!

Status
Not open for further replies.

aejester

Programmer
Aug 29, 2001
52
CA
why does this line of code....

Dim db as Database

generate the following message...

Compile error:
User-defined type not defined


I took this straight from the Access help files and I have used this before without problems. And now this....

Anyone have any clue what is going on?
 
you may want to check tools >> references>> microsoft DAO 3.X objects library<make sure it is checked

HTH
RAVEN
 
These are my references...

Visual Basic for Applications
Microsoft Access 8.0 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft Mappoint Control 9.0
AutoCad DwgThumbnail Control module
Microsoft Visual Basic for Applications Extensibility 5.3

When I try to declare db as a database by typing &quot;Dim db as &quot; the word &quot;database&quot; does not even come up as an option...
 
Hi!

As Raven says make sure DAO is selected(DAO stands for Data Access Objects). Then, in your declaration, use DAO.Database and you will be fine. If you want to learn ADO you can declare an object as an ADO.Database, but you will need to open the connection differently.

hth
Jeff Bridgham
bridgham@purdue.edu
 
OK I added DAO and now the database part works,

But now i get an error message at the line

rs.Close

saying Method or data member not found

Here is my code...

Dim db As Database 'This generates an error for some reason
Dim rs As Recordset
Dim strSQL As String
Dim points() As Long
Dim i As Integer
i = 1

' Return reference to current database.
Set db = CurrentDb
strSQL = &quot;SELECT * FROM qryMaintenanceScheduleToday&quot;
Set rs = db.OpenRecordset(strSQL)

Do While Not rs.EOF
ReDim points(i)
ReDim posX(i)
ReDim posY(i)
points(i) = rs.Fields(&quot;EquipmentIdentifier&quot;)
posX(i) = rs.Fields(&quot;XCoord&quot;)
posY(i) = rs.Fields(&quot;YCoord&quot;)
i = i + 1

'Temporarily display the point for testing purposes
MsgBox &quot;Point &quot; & i & &quot;: &quot; & points(i)

Loop
rs.Close
Set rs = Nothing
Set db = Nothing
 
OK I added DAO and now the database part works,

But now i get an error message at the line

rs.Close

saying Method or data member not found

Here is my code...

Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim points() As Long
Dim i As Integer
i = 1

' Return reference to current database.
Set db = CurrentDb
strSQL = &quot;SELECT * FROM qryMaintenanceScheduleToday&quot;
Set rs = db.OpenRecordset(strSQL)

Do While Not rs.EOF
ReDim points(i)
ReDim posX(i)
ReDim posY(i)
points(i) = rs.Fields(&quot;EquipmentIdentifier&quot;)
posX(i) = rs.Fields(&quot;XCoord&quot;)
posY(i) = rs.Fields(&quot;YCoord&quot;)
i = i + 1

'Temporarily display the point for testing purposes
MsgBox &quot;Point &quot; & i & &quot;: &quot; & points(i)

Loop
rs.Close
Set rs = Nothing
Set db = Nothing
 
only thing I can see is

Dim db As DAO.Database
Dim rs As DAO.Recordset

may try moving the reference to microsoft DAO 3.X objects library up in priority
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top