meds
meds

Reputation: 22926

Viewing SQL in an access database?

I have an access database which has some sql queries loaded into it. I have no experience with microsoft access and need to know how I can see the sql queries it contains. My guess is they are somewhere in r_[sql name]?

What I mean specifically is to see the query itself, for example there is a form which generates an output based on various tables, my guess is there is an SQL query (like Select * from table;) doing this and I'd like to know how I can see it

Upvotes: 0

Views: 263

Answers (3)

David-W-Fenton
David-W-Fenton

Reputation: 23067

You should also note that objects in Access that return recordsets (forms, reports, combo boxes, listboxes) can also have SQL properties. These cannot be seen except by examining the objects themselves (recordsource for forms/reports, rowsource for combo boxes/listboxes). So, just looking at the SQL of the stored QueryDefs is not going to show you all the SQL statements used in the app.

Additionally, if there's VBA code, there could also be SQL embedded in the code.

Upvotes: 2

Thorsten
Thorsten

Reputation: 13181

For each individual query, you can go to the 'View SQL', either using the button or choosing the menu option. (I only have a German access, but it should be something like View - View SQL or so).

Upvotes: 1

Adriaan Stander
Adriaan Stander

Reputation: 166356

It you are refering to view the query names and defs from VBA, the you can try

Private Sub Command0_Click()
Dim qd As queryDef
Dim queryName As String
Dim queryText As String
    For Each qd In CurrentDb.QueryDefs
        queryName = qd.Name
        queryText = qd.SQL
    Next qd
End Sub

Upvotes: 0

Related Questions