PC Review


Reply
Thread Tools Rate Thread

How can I call Parameterized Query in a query of Access?

 
 
devel
Guest
Posts: n/a
 
      16th Sep 2003
Help!

I have a cmpilex query in access, and better to devide into several
subqueries, but parameters are necessary.
How can I call Parameterized Query in a query?


Thanks!


 
Reply With Quote
 
 
 
 
Michel Walsh
Guest
Posts: n/a
 
      16th Sep 2003
Hi,

You just insert it as if it was a table. The "outermost" query would see
the parameters too, as field name coming from the embedded query.



Hoping it may help,
Vanderghast, Access MVP


"devel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Help!
>
> I have a cmpilex query in access, and better to devide into several
> subqueries, but parameters are necessary.
> How can I call Parameterized Query in a query?
>
>
> Thanks!
>
>



 
Reply With Quote
 
 
 
 
devel
Guest
Posts: n/a
 
      18th Sep 2003
Thank You Very Much!
It do Work!

There is another question encountered.
That is Calling parameterized query with a parameter generated by the
caller.
If it can go, how can I get through?

Thanks.



The Query is:

SELECT
(select IndexTable.name from IndexTable where IndexTable.value =
STable.number_1 ) AS Field_1,
(select IndexTable.name from IndexTable where IndexTable.value =
STable.number_2 ) AS Field_2,
:
:
:
(select IndexTable.name from IndexTable where IndexTable.value =
STable.number_n ) AS Field_n
FROM STable;



Another solution as follows:

First define a subquery named "GetIndexName":
PARAMETERS IndexValue Short;
SELECT IndexTable.name FROM IndexTable WHERE IndexTable.value =
[IndexValue];

Then the desired query should like:
SELECT
{CALL GetIndexName(STable.number_1)}.name as Field_1,
{CALL GetIndexName(STable.number_1)}.name as Field_2,
:
:
:
{CALL GetIndexName(STable.number_1)}.name as Field_n
FROM STable;




"Michel Walsh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> You just insert it as if it was a table. The "outermost" query would

see
> the parameters too, as field name coming from the embedded query.
>
>
>
> Hoping it may help,
> Vanderghast, Access MVP
>
>
> "devel" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Help!
> >
> > I have a cmpilex query in access, and better to devide into several
> > subqueries, but parameters are necessary.
> > How can I call Parameterized Query in a query?
> >
> >
> > Thanks!
> >
> >

>
>



 
Reply With Quote
 
Michel Walsh
Guest
Posts: n/a
 
      18th Sep 2003
Hi,


Instead of


SELECT
(select IndexTable.name from IndexTable where IndexTable.value =
STable.number_1 ) AS Field_1,
(select IndexTable.name from IndexTable where IndexTable.value =
STable.number_2 ) AS Field_2,
:
:
:
(select IndexTable.name from IndexTable where IndexTable.value =
STable.number_n ) AS Field_n
FROM STable;



try a more conventionnal syntax:


SELECT i1.name, i2.name, i3.name, ... i_n.name
FROM ((( ... ( STable LEFT JOIN IndexTable As i1 ON
STable.number1=i1.number1)
LEFT JOIN IndexTable As i2 ON STable.Number2=i2.number2)
LEFT JOIN IndexTable As i3 ON STable.Number3=i3.number3)
... )
LEFT JOIN IndexTable As i_n ON STable.NumberN = i_n.NumberN


From that point, I don't understand what you want. If you have a parameter
(or many parameters) in the WHERE clause, or in STable if STable is itself a
query, or in IndexTable, then, in VBA, you can do something like this to
specify each parameter:

===========================================
Dim param as DAO.Parameter
Dim qdf As DAO.QueryDef
Dim db As Database : Set db=CurrentDb


Set qdf= db.QueryDefs(" query name here ")
For each param in qdf.Parameters
set param = ... ' the parameter name is param.Name,
' up to you to specify the value you want for it,
here
Next param


Dim rst As DAO.Recordset
Set rst=qdf.OpenRecordset( ... options, if any, here ... )

=============================================



Hoping it may help,
Vanderghast, Access MVP



"devel" <(E-Mail Removed)> wrote in message
news:O$(E-Mail Removed)...
> Thank You Very Much!
> It do Work!
>
> There is another question encountered.
> That is Calling parameterized query with a parameter generated by the
> caller.
> If it can go, how can I get through?
>
> Thanks.
>
>
>
> The Query is:
>
> SELECT
> (select IndexTable.name from IndexTable where IndexTable.value =
> STable.number_1 ) AS Field_1,
> (select IndexTable.name from IndexTable where IndexTable.value =
> STable.number_2 ) AS Field_2,
> :
> :
> :
> (select IndexTable.name from IndexTable where IndexTable.value =
> STable.number_n ) AS Field_n
> FROM STable;
>
>
>
> Another solution as follows:
>
> First define a subquery named "GetIndexName":
> PARAMETERS IndexValue Short;
> SELECT IndexTable.name FROM IndexTable WHERE IndexTable.value =
> [IndexValue];
>
> Then the desired query should like:
> SELECT
> {CALL GetIndexName(STable.number_1)}.name as Field_1,
> {CALL GetIndexName(STable.number_1)}.name as Field_2,
> :
> :
> :
> {CALL GetIndexName(STable.number_1)}.name as Field_n
> FROM STable;
>
>
>
>
> "Michel Walsh" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> >
> > You just insert it as if it was a table. The "outermost" query would

> see
> > the parameters too, as field name coming from the embedded query.
> >
> >
> >
> > Hoping it may help,
> > Vanderghast, Access MVP
> >
> >
> > "devel" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Help!
> > >
> > > I have a cmpilex query in access, and better to devide into several
> > > subqueries, but parameters are necessary.
> > > How can I call Parameterized Query in a query?
> > >
> > >
> > > Thanks!
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to make generalized methods that accept parameterized references to call other methods? Microsoft C# .NET 3 22nd Jun 2007 11:19 PM
Forgot Syntax: calling a parameterized constructor of the same class from a non-parameterized one Sathyaish Microsoft C# .NET 5 5th Apr 2007 02:25 PM
How do I properly call an Access parameterized wildcard query from ASP? Dave Microsoft Access Queries 4 26th Mar 2007 12:26 PM
Passing a Query to a Parameterized Crosstab Query PEJO Microsoft Access Queries 1 27th Jul 2006 05:21 PM
How to call parameterized stored procedure to return result set? Lacka Microsoft ASP .NET 2 31st Dec 2004 04:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:48 PM.