How to dynamically compile Where Clause

Kowalski

Registered User.
Local time
Today, 05:43
Joined
Jul 5, 2007
Messages
121
Hi
Is it possible to have a dynamic whereclause to a query?
I.e. one that is generated by a Function?

E.g.
Code:
SELECT a, b, c
FROM MyTable
WHERE GetWhere()

GetWhere will then return a string like 'a > 3 AND b < 3'

I have tested this scenario and it is not working, so maybe there is some work around?
 
The answer is Yes and No.

Yes - Through VBA.
No - Through pre compiled Queries.
 
something like:
Select a,b,c
from mytable
where a = [Give A value]
and b = [Give B value]
??

Failing that, you will need to create some code to go dynamicaly query your DB.
 
Thanks. VBA it will be then. Was hoping for a predefined query.
 
You can still use a predefined query. In VBA you use a QueryDef object to get at its SQL and then replace the WHERE clause in the SQL.
 

Users who are viewing this thread

Back
Top Bottom