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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top