Solved List all query name in an Access database

Posted on 2014-08-10
Last Modified: 2014-08-10

What code would I use to add all the query names in an Access database to a
ComboBox. I use a connection string to connect to the Access Database

Question by:murbro
    LVL 74

    Accepted Solution

    If you add a reference to the "Microsoft Access 14.0 Object Library", or whichever version you have installed, then you should be able to open the database and loop over the queries using something like:

    Module Module1
        Sub Main()
            Dim y As New Microsoft.Office.Interop.Access.Dao.DBEngine()
            Dim x As Microsoft.Office.Interop.Access.Dao.Database = y.OpenDatabase("C:\path\to\database.accdb")
            For Each query As Microsoft.Office.Interop.Access.Dao.QueryDef In x.QueryDefs
        End Sub
    End Module

    Open in new window


    Author Closing Comment

    Thanks very much

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now