Andy Lacey
andy at minstersystems.co.uk
Mon Aug 2 02:02:36 CDT 2004
Hiya Darren, Yep, in Steve's answer just replace Set q = currentdb.querydefs("sel_qry_AllOrders") with Set q = currentdb.querydefs(Me.RecordSource) -- Andy Lacey http://www.minstersystems.co.uk > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darren DICK > Sent: 02 August 2004 06:26 > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] A2K: Is is possible to get the SQL of > a query throughVBA > > > Hi Steve > This is way cool - I can see the potential already > > I have a new challenge - can this be done where the > Me.recordsource for a form is a query, but changes between 3 > or 4 queries, dependant on users selection? instead of the > qrydef object? > > Many thanks > > Darren > > > > > > > > > > > > ----- Original Message ----- > From: "Steve Conklin (Developer at UltraDNT)" <Developer at UltraDNT.com> > To: "'Access Developers discussion and problem solving'" > <accessd at databaseadvisors.com> > Sent: Monday, August 02, 2004 2:01 PM > Subject: RE: [AccessD] A2K: Is is possible to get the SQL of > a query throughVBA > > > > 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 > > > > -- > > _______________________________________________ > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > -- > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/a> ccessd > Website: > http://www.databaseadvisors.com > >