Query Problem...

M

Malik

Hi,
I Have Many Tables in my DataBase. Now I have Two Quries "QuerySales" And
"QueryDrVoucher"

When I Run my first Query "QuerySales", It shows result as Follow:

SaleId Date CustomerId CommId NoOfBags Rate
------------------------------------------------------------------------------
---------
1 19/02/09 2 1 50 410
3 19/02/09 2 2 50 450
3 19/02/09 2
4 19/02/09 2 3 50 350
5 19/02/09 2 4 50 2300
6 19/02/09 2 1 50 410
6 19/02/09 2 2 50 850
6 19/02/09 2 3 50 350
6 19/02/09 2 4 50 2300
8 19/02/09 3 2 50 410
8 19/02/09 3 3 50 410
9 19/02/09 1 1 50 410
38 17/02/09 2 2 2 2

Its Fine. Its Ok
And
When I Run "QueryDrVoucher" It Show the Following:

VouccherNo Voucher Date AccountNo DrAmount Narration
------------------------------------------------------------------------------
------------------
2 17/02/2009 2 50000 Cash Paid
3 17/02/2009 2 50000 Cash
4 17/02/2009 3 60000 Cash
5 17/02/2009 4 50000 Cash Paid
6 17/02/2009 2 10000 Cash Paid
7 17/02/2009 2 100000 Cash Paid

Its fine also.

Now the problem is in its Union Query. When i Run Their Union Query, It Show
the Following:
( May Be Results not Fil On This Screen, U can use the Following Link for A
ScreenShot)

http://www.geocities.com/zubair_malik10/Full.JPG

SaleId Date CustomerId CommId NoOfBags Rate VoucherNo VoucherDate AccountNo
DrAmount Narration
1 19/02/09 2 1 50 410 2 17/02/2009 2 50000 Cash Paid
3 19/02/09 2 2 50 450 2 17/02/2009 2 50000 Cash Paid
3 19/02/09 2 2 17/02/2009 2 50000 Cash Paid
4 19/02/09 2 3 50 350 2 17/02/2009 2 50000 Cash Paid
5 19/02/09 2 4 50 2300 2 17/02/2009 2 50000 Cash Paid
6 19/02/09 2 1 50 410 2 17/02/2009 2 50000 Cash Paid
6 19/02/09 2 2 50 850 2 17/02/2009 2 50000 Cash Paid
6 19/02/09 2 3 50 350 2 17/02/2009 2 50000 Cash Paid
6 19/02/09 2 4 50 2300 2 17/02/2009 2 50000 Cash Paid
38 17/02/09 2 2 2 2 2 17/02/2009 2 50000 Cash Paid
1 19/02/09 2 1 50 410 3 17/02/2009 2 50000 Cash
3 19/02/09 2 2 50 450 3 17/02/2009 2 50000 Cash
3 19/02/09 2 3 17/02/2009 2 50000 Cash
4 19/02/09 2 3 50 350 3 17/02/2009 2 50000 Cash
5 19/02/09 2 4 50 2300 3 17/02/2009 2 50000 Cash
6 19/02/09 2 1 50 410 3 17/02/2009 2 50000 Cash
6 19/02/09 2 2 50 850 3 17/02/2009 2 50000 Cash
6 19/02/09 2 3 50 350 3 17/02/2009 2 50000 Cash
6 19/02/09 2 4 50 2300 3 17/02/2009 2 50000 Cash
38 17/02/09 2 2 2 2 3 17/02/2009 2 50000 Cash
8 19/02/09 3 2 50 410 4 17/02/2009 3 60000 Cash
8 19/02/09 3 3 50 410 4 17/02/2009 3 60000 Cash
1 19/02/09 2 1 50 410 6 17/02/2009 2 10000 Cash Paid
3 19/02/09 2 2 50 450 6 17/02/2009 2 10000 Cash Paid
3 19/02/09 2 6 17/02/2009 2 10000 Cash Paid
4 19/02/09 2 3 50 350 6 17/02/2009 2 10000 Cash Paid
5 19/02/09 2 4 50 2300 6 17/02/2009 2 10000 Cash Paid
6 19/02/09 2 1 50 410 6 17/02/2009 2 10000 Cash Paid
6 19/02/09 2 2 50 850 6 17/02/2009 2 10000 Cash Paid
6 19/02/09 2 3 50 350 6 17/02/2009 2 10000 Cash Paid
6 19/02/09 2 4 50 2300 6 17/02/2009 2 10000 Cash Paid
38 17/02/09 2 2 2 2 6 17/02/2009 2 10000 Cash Paid
1 19/02/09 2 1 50 410 7 17/02/2009 2 100000 Cash Paid
3 19/02/09 2 2 50 450 7 17/02/2009 2 100000 Cash Paid
3 19/02/09 2 7 17/02/2009 2 100000 Cash Paid
4 19/02/09 2 3 50 350 7 17/02/2009 2 100000 Cash Paid
5 19/02/09 2 4 50 2300 7 17/02/2009 2 100000 Cash Paid
6 19/02/09 2 1 50 410 7 17/02/2009 2 100000 Cash Paid
6 19/02/09 2 2 50 850 7 17/02/2009 2 100000 Cash Paid
6 19/02/09 2 3 50 350 7 17/02/2009 2 100000 Cash Paid
6 19/02/09 2 4 50 2300 7 17/02/2009 2 100000 Cash Paid
38 17/02/09 2 2 2 2 7 17/02/2009 2 100000 Cash Paid

But I Want That The Data Should Be Shown in One of the Following:

http://www.geocities.com/zubair_malik10/Want1.JPG
http://www.geocities.com/zubair_malik10/Want2.JPG
http://www.geocities.com/zubair_malik10/Want3.JPG


I m Very Confused....
I Need this Union Query For My Report


Thanks
 
D

Dale Fye

Given what you have provided, I seriously doubt that you have a "Union"
query. The format of a UNION query looks something like:

SELECT Field1, Field2, Field3, ...
FROM someTableOrQuery
UNION
SELECT Field1, Field2, Field3, ...
FROM someOtherTableOrQuery

where each of the fields in the sequence must match in datatype between the
two (or more) parts of the query. If you use UNION to join the various
elements of the query, JET will eliminate the duplicates (where every field
matches). But if you want to include all of the values, regardless of
duplicates, use "UNION ALL"

What does your SQL string look like for the last query? I don't see any
fields that look like they would match for either a UNION query, or a JOIN.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 

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