[AccessD] A2K: Is is possible to get the SQL of a query through VBA

Steve Conklin (Developer@UltraDNT) Developer at UltraDNT.com
Sun Aug 1 23:01:44 CDT 2004


Dim q as DAO.Querydef
Dim s as string

Set q = currentdb.querydefs("sel_qry_AllOrders")
S=q.SQL

' S now holds SELECT tblOrders.* FROM tblOrders;

Happy coding,
Steve


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darren DICK
Sent: Sunday, August 01, 2004 11:23 PM
To: AccessD List
Subject: [AccessD] A2K: Is is possible to get the SQL of a query through
VBA


Hello all
Say I have a query called sel_qry_AllOrders. It simply shows all order
details The SQL for sel_qry_AllOrders is..."SELECT tblOrders.* FROM
tblOrders;"

Is it possible for me to get the query object and 'read' its SQL syntax
eg

pseudo code

Dim MyQuery as query

query = "sel_qry_AllOrders"

debug.print "All orders query as SQL = " &
SomethingCoolHereThatGetsTheSQLComponentOfTheQuery

and have the debug result say

All orders query as SQL = SELECT tblOrders.* FROM tblOrders;

Many thanks

Darren

-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list