DAO in VB5 yields User-defined type not defined 
Author Message
 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.



Fri, 12 Oct 2001 03:00:00 GMT  
 DAO in VB5 yields User-defined type not defined
In the VB menu, go to Projects | References and search the list for "Microsoft
DAO 3.X Object Library", select it (make sure the checkbox has a check in it),
and click OK.  Try to run your program again, and, as if by magic, you won't
get the error any more.

Lee Weiner
weiner AT fuse DOT net
http://home.fuse.net/lweiner



Quote:
>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



Sat, 13 Oct 2001 03:00:00 GMT  
 DAO in VB5 yields User-defined type not defined
In components add DAO 3.51
Quote:

>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.



Sun, 14 Oct 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. User Control - User-defined type not defined

2. User Defined Type Not Defined

3. Compile Error: User-defined type not defined

4. User-defined type not defined (Access 97)

5. Excel : User-defined type not define

6. Compile Error - User defined type not defined

7. User-defined type not defined (Access 2000)

8. Dim oappWD as Word.Application: User defined type not defined

9. User- Defined type not defined

10. User Define Type Not Defined

11. FileSystemObject "User Defined Type Not Defined"

12. Compile Error - User-Defined type not defined

 

 
Powered by phpBB® Forum Software