How to read an SQL line??

D

DVN

How do you write code to read a query's SQL lines and
store it into a string variable?

Thanks for your help.
 
R

Roger Carlson

With DAO, you can do this:

Dim varQDef As QueryDef
Dim strSQL As String

Set varQDef = CurrentDb.QueryDefs("TheQuery")
strSQL = varQDef.SQL

'Remove carriage return line feed and the semi colon from the end of the
string.
strSQL = Left(strSQL, Len(strSQL) - 3)
 
M

Marshall Barton

DVN said:
How do you write code to read a query's SQL lines and
store it into a string variable?

strSQL = CurrentDb.QueryDefs("queryname").SQL
 
Top