troubleshooting Question

Access - help with combining two queries

Avatar of doe5
doe5 asked on
Microsoft AccessVisual Basic ClassicSQL
5 Comments1 Solution358 ViewsLast Modified:
I am trying to combine two queries -- is this possible for the following queries? I want to combine the queries to create a report from the combined query.  Ultimately I'd like to combine 3.  The problem I'm having is the two queries return similar fields but need different selection criteria --- one needs to pull with selection criteria from fields [order mthyr] and [need mthyr] = xxx and the other needs to pull with selection criteria from  [order mthyr] and [prom mthyr]=xxx

Can these two queries be combined into one? if so, how?

I am using a parameter in one but would like both to use a parameter in both.

Query 1:
SELECT bookings.[Prod Line], bookings.[Need MthYr], Sum(bookings.[Ord Qty]) AS [SumOfOrd Qty], Sum(bookings.[Ext Price]) AS [SumOfExt Price]
FROM bookings
GROUP BY bookings.[Prod Line], bookings.[Need MthYr], bookings.[Order MthYr], bookings.[Prod Type]
HAVING (((bookings.[Prod Line]) Is Not Null) AND ((bookings.[Need MthYr])="jan 2012") AND ((Sum(bookings.[Ord Qty])) Not Like "0") AND ((bookings.[Order MthYr])="jan 2012"))
ORDER BY bookings.[Prod Type];



Query 2:
PARAMETERS [Promised Month Year - mmm yyyy] Text ( 255 );
SELECT bookings.[Prod Line], bookings.[Prom MthYr], Sum(bookings.[Ord Qty]) AS [SumOfOrd Qty], Sum(bookings.[Ext Price]) AS [SumOfExt Price]
FROM bookings
GROUP BY bookings.[Prod Line], bookings.[Prom MthYr], bookings.[Order MthYr], bookings.[Prod Type]
HAVING (((bookings.[Prom MthYr])=[Promised Month Year - mmm yyyy]) AND ((bookings.[Order MthYr])=[Promised Month Year - mmm yyyy]))
ORDER BY bookings.[Prod Line], bookings.[Prod Type];
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros