
DAO in VB5 yields User-defined type not defined
I'm trying to use DAO for the first time in VB5 and I get "User-defined
type not defined" messages whenever I try to declare a Database, etc.
I'd previously used DAO it in VB3 and VB4. I've even tried pasting the
following code exactly from a sample in VB5 online help and I still get
the "User-defined type not defined" on the Dim wrkJet As Workspace
line. Is there anything that I need to include in my code to allow DAO?
Sample code follows:
Dim wrkJet As Workspace
Dim dbsNorthwind As Database
Dim dbsPubs As Database
Dim dbsPubs2 As Database
Dim dbsLoop As Database
Dim prpLoop As Property
' Create Microsoft Jet Workspace object.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
' Open Database object from saved Microsoft Jet database
' for exclusive use.
MsgBox "Opening Northwind..."
Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb", True)
' Open read-only Database object based on information in
' the connect string.
MsgBox "Opening pubs..."
Set dbsPubs = wrkJet.OpenDatabase("Publishers", _
dbDriverNoPrompt, True, _
"ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")
' Open read-only Database object by entering only the
' missing information in the ODBC Driver Manager dialog
' box.
MsgBox "Opening second copy of pubs..."
Set dbsPubs2 = wrkJet.OpenDatabase("Publishers",
dbDriverCompleteRequired, True, "ODBC;DATABASE=pubs;DSN=Publishers;")
' Enumerate the Databases collection.
For Each dbsLoop In wrkJet.Databases
Debug.Print "Database properties for " & _
dbsLoop.Name & ":"
On Error Resume Next
' Enumerate the Properties collection of each Database
' object.
For Each prpLoop In dbsLoop.Properties
If prpLoop.Name = "Connection" Then
' Property actually returns a Connection object.
Debug.Print " Connection[.Name] = " & _
dbsLoop.Connection.Name
Else
Debug.Print " " & prpLoop.Name & " = " & _
prpLoop
End If
Next prpLoop
On Error GoTo 0
Next dbsLoop
dbsNorthwind.Close
dbsPubs.Close
dbsPubs2.Close
wrkJet.Close
--
If you want to respond by e-mail, please delete what's between Eric and
Goforth to get my real e-mail address.