DMW logo

How to List All Queries in an Access Database

How to create VBA functions to list in the Immediate Window of its Visual Basic Editor all the queries of a Microsoft® Access database.

Last updated on 2020-05-26 by David Wallis.

VBA Function to List All Queries

This function lists all the queries in the database in which you execute it:

Function fnDmwListAllQueries() As String

On Error GoTo errHandler

Dim msg$

Dim qry As AccessObject, dB As Object

Set dB = Application.CurrentData

For Each qry In db.AllQueries

Debug.Print qry.Name

Next qry

msg$ = "Queries listing complete"


fnDmwListAllQueries = msg$

Exit Function


msg$ = Err.Number & " " & Err.Description

Resume procDone

End Function

How to Run Your Function

To execute the function copy and paste its code shown above into a module in your database’s Visual Basic Editor. Then in the Editor’s Immediate Window type ?fnDmwListAllQueries() and press Enter. Don’t omit the leading question mark.

Your Support for DMW TIPS

Please support this website by making a donation to help keep it free of advertising and to help towards cost of time spent adding new content.

To make a contribution by PayPal in GBP (£ sterling) —

To make a contribution by PayPal in USD ($ US) —

Thanks, in anticipation.


DMW Consultancy Ltd does not accept any liability for loss or damage to data to which any techniques, methods or code included in this website are applied. Back up your data; test thoroughly before using on live data.

“Lists are how I parse and manage the world.”

Adam Savage