Trouble with union qry

T

tsison7

Below is a union query which gathers up shipment and returns to give data
representing quality (total returned/total shipped). The query works fine
without the WHERE statement for all customers. But I want to filter it out
for a specific Account Manager's customer's only.

I tried the WHERE statement below, but it doesn't work.

WHERE (((qryQualityRGA.AcctmgrID)=getmyvariable()));

Interesting to me is using that last statement brings up a parameter box
asking for the value of qryQualityRGA.AcctmgrID????


SELECT qryQualityRGA.plant, qryQualityRGA.AcctmgrID,
qryQualityRGA.TransactionDate, qryQualityRGA.QuantityReturned,
qryQualityRGA.QuantityShipped FROM qryQualityRGA UNION ALL SELECT
qryQualityShipped.plant, qryQualityShipped.AcctmgrID,
qryQualityShipped.TransactionDate, qryQualityShipped.QuantityReturned,
qryQualityShipped.QuantityShipped FROM qryQualityShipped
WHERE (((qryQualityShipped.AcctmgrID)=getmyvariable()));
 
M

Marshall Barton

tsison7 said:
Below is a union query which gathers up shipment and returns to give data
representing quality (total returned/total shipped). The query works fine
without the WHERE statement for all customers. But I want to filter it out
for a specific Account Manager's customer's only.

I tried the WHERE statement below, but it doesn't work.

WHERE (((qryQualityRGA.AcctmgrID)=getmyvariable()));

Interesting to me is using that last statement brings up a parameter box
asking for the value of qryQualityRGA.AcctmgrID????


SELECT qryQualityRGA.plant, qryQualityRGA.AcctmgrID,
qryQualityRGA.TransactionDate, qryQualityRGA.QuantityReturned,
qryQualityRGA.QuantityShipped FROM qryQualityRGA UNION ALL SELECT
qryQualityShipped.plant, qryQualityShipped.AcctmgrID,
qryQualityShipped.TransactionDate, qryQualityShipped.QuantityReturned,
qryQualityShipped.QuantityShipped FROM qryQualityShipped
WHERE (((qryQualityShipped.AcctmgrID)=getmyvariable()));


Each SELECT statemet has a separate WHERE clause, not one
WHERE clause for all SELECT statements in the UNION.

In this case, I think you need to move it up before UNION
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top