C
Carl Colijn
Hi all,
In my Access 2003 DB I have a query (named, say, 'Base') that accepts a
parameter (named 'ParamBase'). Now I want to use this query as the source
for another query (named 'Derived'), which also has a parameter (named
'ParamDerived'). I want to use the value supplied in 'ParamDerived' as the
value for the parameter 'ParamBase' in the 'Base' query.
I know you can store the value of the parameter to pass to the 'Base' query
somewhere else in e.g. a field in an unbound (possibly hidden) form, or
supply it via a VBA function that knows what's going on. But I want to use
pure SQL to keep the database somewhat manageable
I already looked at the SQL keywords EXECUTE and PROCEDURE, but they didn't
really lead me to a working solution...
So, what I want to derive at is something like this:
Query 'Base':
PARAMETER nParamBase Long;
SELECT * FROM Table_Base WHERE Column=nParamBase;
Query 'Derived':
PARAMETER nParamDerived Long;
SELECT * FROM Base(nParamDerived) <== invalid syntax, I know...
The real-world example is a bit more complicated; the 'Derived' query
performs a SELECT on a table based on criteria of it's own parameters, and
the result from this needs to be used as a parameter to the 'Base' query. I
don't want to use VBA and/or forms because, in my opinion, it tends to get
messy quite easy and I like to separate the SQL from the actual client side
VBA code and forms as well.
Do I have any alternatives to VBA and/or forms?
Kind regards,
Carl Colijn
In my Access 2003 DB I have a query (named, say, 'Base') that accepts a
parameter (named 'ParamBase'). Now I want to use this query as the source
for another query (named 'Derived'), which also has a parameter (named
'ParamDerived'). I want to use the value supplied in 'ParamDerived' as the
value for the parameter 'ParamBase' in the 'Base' query.
I know you can store the value of the parameter to pass to the 'Base' query
somewhere else in e.g. a field in an unbound (possibly hidden) form, or
supply it via a VBA function that knows what's going on. But I want to use
pure SQL to keep the database somewhat manageable
I already looked at the SQL keywords EXECUTE and PROCEDURE, but they didn't
really lead me to a working solution...
So, what I want to derive at is something like this:
Query 'Base':
PARAMETER nParamBase Long;
SELECT * FROM Table_Base WHERE Column=nParamBase;
Query 'Derived':
PARAMETER nParamDerived Long;
SELECT * FROM Base(nParamDerived) <== invalid syntax, I know...
The real-world example is a bit more complicated; the 'Derived' query
performs a SELECT on a table based on criteria of it's own parameters, and
the result from this needs to be used as a parameter to the 'Base' query. I
don't want to use VBA and/or forms because, in my opinion, it tends to get
messy quite easy and I like to separate the SQL from the actual client side
VBA code and forms as well.
Do I have any alternatives to VBA and/or forms?
Kind regards,
Carl Colijn