Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Nov 2001
    Location
    Newark, New Jersey, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Listing Queries from another database (2003)

    Does anyone have experience pulling a list of queries from a different database? I found code (using the currentdata.allqueries method) which allows me to pull the list of queries from the current database, but having trouble trying to modify it to connect to a different database.

    Any help would be greatly appreciated!
    Thanks!

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

    Re: Listing Queries from another database (2003)

    I'd use DAO: set a reference to the Microsoft DAO 3.6 Object Library in Tools | References in the Visual Basic Editor.
    You can then use code like this:

    Sub ListQueries()
    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef
    ' Substitute database path and filename
    Set dbs = DBEngine.OpenDatabase("C:Test.mdb")
    For Each qdf In dbs.QueryDefs
    ' Your code goes here, for example
    Debug.Print qdf.Name
    Next qdf
    Set qdf = Nothing
    dbs.Close
    Set dbs = Nothing
    End Sub

  3. #3
    Lounger
    Join Date
    Nov 2001
    Location
    Newark, New Jersey, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listing Queries from another database (2003)

    Thanks Hans - that works well.

Posting Permissions

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