Union does not show all records

  • Thread starter Gaetanm via AccessMonster.com
  • Start date
G

Gaetanm via AccessMonster.com

I appear to be losing records in a union query results

My Union query brings up 13 parts for Job 120.

If I query Parts separately I get 11 parts

If I query Myob separately I get 5 parts

In my separate Parts query I have 4 parts that are
identical but the Union only shows one.
16 Items is the correct answer. Does a union
Get rid of duplicates? If so what would be the solution

Any ideas? Below is my SQL for the union

SELECT [Job Sheet].[Job ID], Parts.ProductDescription, Parts.Quanity, ([Unit
Price]*parts.[Mark up])+([unit Price]) AS Unit_Markup, ([Unit_markup]*
[Quanity]) AS Extended_cost, [Job Sheet].Notes, Customers.CompanyName
FROM ((Customers INNER JOIN [Job Sheet] ON Customers.CustomerID = [Job Sheet].
CustomerID) INNER JOIN Parts ON [Job Sheet].[Job ID] = Parts.[Job ID]) INNER
JOIN Started_Jobs_billable ON [Job Sheet].[Job ID] = Started_Jobs_billable.
[Job ID]
WHERE ((([Job Sheet].[Job ID])=[FORMS]![frm_Invoice]![cboJob_ID]))

UNION SELECT [Myob_cards query].JobNumber, [Myob_cards query].Description,
[Myob_cards query].Quantity, [Myob_cards query].Price, [Myob_cards query].
Extended_Cost, [Job Sheet].Notes, Customers.CompanyName
FROM Customers INNER JOIN ([Job Sheet] INNER JOIN [Myob_cards query] ON [Job
Sheet].Job_Number = [Myob_cards query].JobNumber) ON Customers.CustomerID =
[Job Sheet].CustomerID

WHERE ((([Myob_cards query].JobNumber)=[FORMS]![frm_Invoice]![cboJob_ID]));
 
6

'69 Camaro

Hi.
Does a union
Get rid of duplicates?
Yes.

If so what would be the solution

Use UNION ALL in your query syntax, instead of just UNION. The query will
run faster, too, because the duplicates don't need to be removed from the
displayed rows.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
G

Guest

Congratulations on the MVP award Gunny! Nice to see some more women in the
Access MVP ranks.
 
G

Gaetanm via AccessMonster.com

Thanks Gunny that was it

Gaetanm

'69 Camaro said:
Hi.


Use UNION ALL in your query syntax, instead of just UNION. The query will
run faster, too, because the duplicates don't need to be removed from the
displayed rows.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
6

'69 Camaro

JH said:
Congratulations on the MVP award Gunny!

Thank you very much. But I'm at a loss as to who you are, because I can't
think of anyone I know of with your initials. You created a brand new
Windows Live ID identity to post your message, so there aren't any hints,
either. Would you please shed some light on the mystery?

Thanks.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 

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

Null 3
Union Query Edit 1
UNUION ALL questions 8
Union query not showing all fields 4
3033 error 1
UNION SELECT "(ALL)" Query Not Working 6
Query leaving out some data 2
Show last records by date? 5

Top