How to read an SQL line??

  • Thread starter Thread starter DVN
  • Start date Start date
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.
 
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)
 
Back
Top