Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Query into SQL (DAO) code

Status
Not open for further replies.

netsmurph

Technical User
Mar 19, 2003
63
GB
I have paramater based querys that i need to able to use through vba as a DAO SQL recordset and am searching for a way to do this without having to re-code each time.

I have looked at the querydef object, and it does not seem suitable.

Has anyone developed any code to do this conversion (although thinking it through, if there are multiple paramaters, and or string or integers, it makes things kinda complex?)

Is it any easier with ADO?

Any help would be appreciated.

Andrew

 
First of all sorry about posting in two forums - was hedging my bets there.

Thanks for your reply ZmrAbdulla, but it is not quite what i am looking for.

Im not sure if it is possible, but i need to be able to convert partameterized access queries (where the partameter is based on a field on a form) into sql code that can be used in an openrecordset procedure.

Working backwards, if i can retrieve the sql string from a query, and add the form based parameters that way, it could be a work around, but i am having trouble getting this from the recordset object:

From the watchwindow, it seems that I need something along the lines of:

rs.parent.QueryDefs.[item1].SQL

Any help on this would be much appreciated.

Andrew
 
Have a look at the Parameters collection of the QueryDef object and the Eval function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Many thanks for your post PHV, have taken a look at it, but cannot find what i am looking for.

What I want is to be able to convert a query into a string, evaluate the where clauses on the end of it and concatenate another form based parameter (string) onto the end of it.

Could anyone point me in the right direction.

Many thanks

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top