How could I combine these 2 queries into one in Access 2007?

A

Aldred@office

Hi all,
Now I have 2 queries, I was asked to display them in the same view in a form
as Datasheet view.

Query 1:
SELECT PartNumID, Manu, POOutNum, PartNum, Quantity, DueDate,
tPOItems.DeliveryDate, SpecialInst
FROM tManu, tPOin, tPOItems, tPOOut
WHERE POinNum=Forms!fReport!POinNumDelivered And tPOin.ID=tPOItems.POinID
And tPOOut.ID=tPOItems.POOutID And tPOOut.ManuID=tManu.ID;


Query 2:
SELECT Sum(tDelivered.DQuantity) AS Delivered
FROM tPOitems, tPOin, tDelivered
WHERE POinNum=Forms!fReport!POinNumDelivered And tPOin.ID=tPOitems.POinID
And tPOitems.ID=tDelivered.POItemsID and tDelivered.PartNumID= "PartNumID
Which Is Equal To The One From Query1"

Is this possible? If not, is there any workaround?

Thanks.
 
D

Dale Fye

Aldred,

Need a little more info about what you would like the output to look like.

There are really only two ways to combine queries.

One method is to use a Union query, but that requires that the number of
fields from each query are the same, and that each of the fields to be
included in the output must be of the same data type - in a field-to-field
matchup.

The other method is to JOIN the two queries based on some common field,
which you do not have in your two queries. If you changed Query #2 so that
it included the PartNumID field in the SELECT statement and in a GROUP BY
clause then you could join the two queries on that field.
 
A

Aldred@office

Ops, Sorry about the confusion.

Originally, we have a query from Query1 which display the following fields:
PartNumID, Manu, POOutNum, PartNum, Quantity, DueDate,
tPOItems.DeliveryDate, SpecialInst

And we want to add an extra field from Query2 which is a sum of somthing
then it looks like this.
PartNumID, Manu, POOutNum, PartNum, Quantity, DueDate,
tPOItems.DeliveryDate, SpecialInst, Sum(tDelivered.DQuantity) AS Delivered

The DQuantity stored the data on how many in quantity we have delivered to
the customers. And now we wanted to display that in one single view in
datasheet view.

Thanks.
 

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

Top