VBA Function to List All Queries in
Microsoft® Access Databases
Last updated on 2020-03-24 by David Wallis.
On this page you’ll find a VBA function that lists all the queries in your current database. The function is for running in the Immediate Window of the Visual Basic Editor where it will output the list of queries.
VBA Function to List All Queries
This function lists all the queries in the database in which you execute it:
Function dmwListAllQueries() As String
On Error GoTo errHandler
Dim qry As AccessObject, dB As Object
Set dB = Application.CurrentData
For Each qry In db.AllQueries
msg$ = "Queries listing complete"
dmwListAllQueries = msg$
msg$ = Err.Number & " " & Err.Description
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 ?dmwListAllQueries() and press Enter. Don’t omit the leading question mark.
Your Support for dmw TIPS
If you’re going to make use of Tips in any of your professional or commercial work, then please consider making a payment in recognition of the time spent publishing this website.
To make a contribution by PayPal in GBP (£ sterling) —
To make a contribution by PayPal in USD ($ US) —
To say how much you want to pay and to receive
a tax invoice for a GBP (£ sterling) contribution —
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.