Hi Guys,
is it possible to change the SQL of a stored query by code?
I, basically, want to create a stored procedure which would be dynamic in so far as it is dependent on the selection on the access form.
Thanks for your help.
There are many ways to skin that particular cat, perhaps if you explained what you intend to do with the results a more directed response could be delivered.
While you cant pass variables to a query as you would a stored procedure you can mimic this pass if you have a function which collects the variable as the criteria for a field. This might help. Or (simpler) dont use a query but use a recordset. I'm not aware of being able to change the underlying SQL of a query in the way you can with a Table using ALTER but you could just delete and recreate the query easliy enough. Though to do so is a bit redundant as a recordset does the job more easily.
Using DAO, it seems changing the SQL contents of the query is rather popular. I don't use DAO so I wouldn't know, but do a search for querydefs (help file and here), and you'll probably find samples where the .sql property of the querydef object is altered.
I am using Views and tables from 2 different DB Schemes for a crystal Report Project which consists of approximately 10 reports. I get the information for my reports via stored queries in access of the linked tables and views from Oracle! The point of having Access in between Crystal Reports and the underlying Oracle Database was merley for a more controlled access.
You see, my stored queries have 2 fators which I eventually want to control on an access form: the customerID and the date!
Now a little form witha combo of the different customerIDs and a combo for the moth should specify, or update my stored procedure to the relevant SQL which I can then just give Crystal Report.
So what is the best way for me to update my stored procedure?? a bit of code would be cool..*G*
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.