Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DAO Container Object

    I'm trying to run the following function from a standard module in Northwind.mdb

    Public Sub ListContainers( _
    Optional ListProps As Boolean = False, _
    Optional ContainerName As String = "ALL")

    ' From Access 2000 Developer's Handbook
    ' by Litwin, Getz, Gilbert (Sybex)
    ' Copyright 1999. All rights reserved.

    ' List contents of containers, all or selected.
    ' Get lists of properties, too, if requested.

    ' In:
    ' ListProps: (optional, default is False)
    ' If True, list properties for all objects
    ' ContainerName: (optional, default is "ALL")
    ' Leave blank for "ALL", or one of
    ' "Databases", "Forms", "Modules", "Relationships"
    ' "Reports", "Scripts", "SysRel", "Tables"

    Dim db As DAO.Database
    Dim con As Container
    Dim doc As DAO.Document
    Dim prp As DAO.Property

    Set db = CurrentDb()
    For Each con In db.Containers
    If ContainerName = "ALL" Or _
    (ContainerName = con.Name) Then
    Debug.Print con.Name
    For Each doc In con.Documents
    Debug.Print , doc.Name
    If ListProps Then
    For Each prp In doc.Properties
    Debug.Print , , prp.Name, prp.Value
    Next prp
    End If
    Next doc
    End If
    Next con
    End Sub

    by typing <font color=red>ListContainers "databases"</font color=red> in the immediate window but all I get is <font color=448800>Run-time error '13': Type mismatch</font color=448800>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DAO Container Object

    ContainerName is the second argument of ListContainers, not the first. Use

    <code>ListContainers , "Databases"</code>

    or if you want to list properties too

    <code>ListContainers True, "Databases"</code>

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DAO Container Object

    Thank you Hans, does ADO have an equivalent to containers?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DAO Container Object

    No, but Access 2000 VBA has introduced new objects:

    CurrentData has AllTables and AllQueries
    CurrentProject has AllForms, AllReports, AllMacros and AllModules

    See the online help for details and sample code.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: DAO Container Object

    But to get at some properties and structure information, you have to use the ADOX object library and the Catalog object.
    Charlotte

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DAO Container Object

    Correct, but I'm not very familiar with ADOX.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: DAO Container Object

    Normally, you only need it in order to modify those objects.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •