Union Query & Combo Box (1 Viewer)

itownson1

Registered User.
Local time
Today, 09:04
Joined
Mar 20, 2019
Messages
43
Good afternoon

I have a union query which is getting some of its data from a combo box result.
Within the union query it is stating the First column rather than the second column.
The data in the table does state the second column as I want it to do, but I can not get the union query to follow suit.

Union Query is
SELECT [ProductionID], [Stock1], [Stock2], [Stock3], [Stock4], [Operative], [1DeliveryID], [1DeliveryProduct], [1Temp] FROM TMeatP
WHERE [1DeliveryID] Is Not Null
UNION ALL
SELECT [ProductionID], [Stock1], [Stock2], [Stock3], [Stock4], [Operative], [2DeliveryID], [2DeliveryProduct], [2Temp] FROM TMeatP
WHERE [2DeliveryID] Is Not Null


The 4 x Stock columns and Operative are combo boxes and all showing the ID number in the union query.

Regards Ian
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:04
Joined
Oct 29, 2018
Messages
21,478
Hi Ian. Is TMeatP a table? If so, I can see two problems with your table's design. First, you have repeating groups, e.g. Stock1, Stock2, etc. And second, you're probably using lookup fields. If it's not too late, you should consider redesigning your table because both of these problems are considered bad designs. If you're stuck with it, one way to fix your UNION query is to union two queries instead of the table. In your query, you would join the lookup table with your main table and pull the Text Description from the lookup table.
 

itownson1

Registered User.
Local time
Today, 09:04
Joined
Mar 20, 2019
Messages
43
The query solution worked, thank you.
I just had one combo that I could add multiple values. Then realised I couldn't union query on a multi value combo box.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:04
Joined
Oct 29, 2018
Messages
21,478
The query solution worked, thank you.
I just had one combo that I could add multiple values. Then realised I couldn't union query on a multi value combo box.
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom