tags:

views:

76

answers:

3

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

A: 

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
astander
+1  A: 

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).

IronGoofy
+1  A: 

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.

David-W-Fenton
+1 but I trust the conclusion is, "...so don't put SQL code in the properties of forms, reports, combo boxes, listboxes, etc."
onedaywhen
Not at all. If you follow that rule, you shouldn't be using Access at all, because you're clearly so hostile to the basica design and purpose of Access that you'll be fighting it at every turn.
David-W-Fenton