Display SQL of a created query

  • Thread starter Thread starter craigathurst
  • Start date Start date
C

craigathurst

Hi All,

I have a query called "qryContactsList1", which has the SQL:

SELECT CDB.*
FROM CDB
WHERE (((CDB.Company) Like '*richland*') AND ((CDB.listdisplay)=True))
ORDER BY CDB.Company;

This query is a saved query (doesn't get re-created).

What i want is to hit a button on a form that displays in a message
box, the SQL statement for the query "qryContactsList1"

Is this possible?


Craig Hurst
 
Hi All,

I have a query called "qryContactsList1", which has the SQL:

SELECT CDB.*
FROM CDB
WHERE (((CDB.Company) Like '*richland*') AND ((CDB.listdisplay)=True))
ORDER BY CDB.Company;

This query is a saved query (doesn't get re-created).

What i want is to hit a button on a form that displays in a message
box, the SQL statement for the query "qryContactsList1"

Is this possible?
Hi Craig,

I believe message is limited to 256 chars
(I could be wrong)

Set Reference to DAO.

in click event of form button

Dim strSQL As String

strSQL = CurrentDb.QueryDefs("qryContactsList1").sql

If Len(strSQL) < 256 Then
Msgbox strSQL
Else
Msgbox "SQL is too long. Printed to Immediate Window."
Debug.Print strSQL
End If

good luck,

gary
 
Back
Top