Just a hunch, but it looks like your [Order Entry] table has multiple
repeating "quantity" fields. While this might be the only way to handle
your data if you were using a spreadsheet, Access is a relational database.
You will not get the best use of Access' features and functions if you don't
normalize your data, and you will have to come up with complex work-arounds
to do "simple" things ... (oops, that's what you've just described!).
Tell us a bit more about your underlying data, not about how you are trying
to query it. In your world, what's the relationship among Customers
(?"Contacts"?), Orders, and Order Details? Not how you've structured your
current tables, but something in English like:
One Customer can have multiple Orders
One Order can have multiple Order Details
No Order is for more than one Customer
A more traditional (relational) database structure for orders can be found
in the Northwind database sample that comes with Access. Something like:
tblCustomer
CustomerID
...
tblOrder
OrderID
CustomerID
OrderDate
...
trelOrderDetail
OrderDetailID
OrderID
ItemID
Quantity
...
--
Good luck & Regards
Jeff Boyce
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
Microsoft Registered Partner
https://partner.microsoft.com/
Durn... Thought I had it covered... Anyhow, here's the SQL:
SELECT [Order Number], CompanyName, SpecID, Alloy, [Thick], [Part Number],
[Qty]
FROM [SELECT [Order Entry].[Order Number], Contacts.CompanyName, [Order
Entry].SpecID, [Order Entry].Alloy, [Order Entry].[Thick 1] as [Thick],
[Order Entry].[Part Number1] as [Part Number], [Order Entry].[QTY 1] as
[Qty]
FROM Contacts INNER JOIN [Order Entry] ON Contacts.ContactID=[Order
Entry].ContactID
WHERE ((([Order Entry].[Order Number]) Is Not Null) and (([Order
Entry].[Part Number1]) Is Not Null))
UNION
SELECT [Order Entry].[Order Number], Contacts.CompanyName, [Order
Entry].SpecID, [Order Entry].Alloy, [Order Entry].[Thick 2] as [Thick],
[Order Entry].[Part Number 2] as [Part Number], [Order Entry].[QTY2] as
[Qty]
FROM Contacts INNER JOIN [Order Entry] ON Contacts.ContactID=[Order
Entry].ContactID
WHERE ((([Order Entry].[Order Number]) Is Not Null) and (([Order
Entry].[Part Number 2]) Is Not Null))
UNION
SELECT [Order Entry].[Order Number], Contacts.CompanyName, [Order
Entry].SpecID, [Order Entry].Alloy, [Order Entry].[Thick 3] as [Thick],
[Order Entry].[Part Number 3] as [Part Number], [Order Entry].[QTY 3] as
[Qty]
FROM Contacts INNER JOIN [Order Entry] ON Contacts.ContactID=[Order
Entry].ContactID
WHERE ((([Order Entry].[Order Number]) Is Not Null) and (([Order
Entry].[Part Number 3]) Is Not Null))
UNION
SELECT [Order Entry].[Order Number], Contacts.CompanyName, [Order
Entry].SpecID, [Order Entry].Alloy, [Order Entry].[Thick 4] as [Thick],
[Order Entry].[Part Number4] as [Part Number], [Order Entry].[QTY4] as
[Qty]
FROM Contacts INNER JOIN [Order Entry] ON Contacts.ContactID=[Order
Entry].ContactID
WHERE ((([Order Entry].[Order Number]) Is Not Null) and (([Order
Entry].[Part Number4]) Is Not Null))
ORDER BY [Order Entry].[Order Number]]. AS [%$##@_Alias]
WHERE [Order Number] is Not Null;
--
Why are you asking me? I dont know what Im doing!
Jaybird
:
Consider posting the SQL statement of your UNION query...
Tough to diagnose if we can't see what you see...
--
More info, please ...
Jeff Boyce
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
Microsoft Registered Partner
https://partner.microsoft.com/
I'm looking for a way to select a specific result of a Union Query as
a
row
source for a combo box. Currently, I cannot specify the exact result
I
want
because, I'm guessing, they are derived from a single record in a
table.
Is
there a way around this? I've tried using the Union Query as a
subquery
in
the row source property, but came up with the same results. Is there
any
way
to do this without creating a new table?