Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an .mdb file that should contain a complex query that I would like to modify.

The .mdb somehow is used to create reports against a database.

If I open the .mdb file, I see all the ribbon options, but I cannot locate a kind of "show existing queries" menu item.

How do I find a pre-existing query in a Microsoft Access file?

share|improve this question

If you do not see any tables, queries, or reports, try opening the .mdb file while holding the shift key. The tables should all appear on the left, or at least a table toolbar. If this is not the case the make sure it is not just pulling from linked tables. You may need to make sure its not loading while hiding tables as well either in VBA or the options, but holding the shift key should bypass that.

The query itself will be in this table toolbar. If you don't know which query you want, try looking at the design view of the report by right clicking the frame of the report or clicking design view in the tools.

share|improve this answer

Try this code

'Press CTRL-G to see debug window

Dim qd As QueryDef

For Each qd In CurrentDb.QueryDefs

    Debug.Print qd.Name

    Debug.Print qd.sql



Set qd = Nothing
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .