Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Union Query 1 1

Status
Not open for further replies.

georgesOne

Technical User
Jul 2, 2004
176
JP
Hi All:

I have the following union query:

SELECT TOP 5 qryGraph00.FNumber, qryGraph00.FDescription, qryGraph00.CStress1, "1" As fRank
FROM qryGraph00
WHERE (((qryGraph00.Model)="3")) And qryGraph00.CStress1>0
ORDER BY qryGraph00.CStress1
UNION SELECT qryGraph00.FNumber, qryGraph00.FDescription, qryGraph00.CStress1, "0" As fRank
from qryGraph00
WHERE (((qryGraph00.Model)="3")) And qryGraph00.FNumber = Forms!frmDisplay.tbxFNumber
ORDER BY fRank, qryGraph00.CStress1;

This query feeds directly a graphic, which shows the values FDescription as x-Value and CStress1 As y-Value. This works as desired (6 value pairs, 5 from the first select part, 1 from the "Union" part), if the "Union" part produces a recordset, but gives only the top 5 values (5 value pairs)if the "Union" part does not produce a recordset (because the table does not contain a value for Model = "3").
How can I manage that the Graphic would show "NA" for the x-Value as FDescription and 0 for the y-value as CStress1 if the "Union" part does not return a recordset?
Thanks for any advice.

georges
 
You may add this UNION:
UNION SELECT Forms!frmDisplay.tbxFNumber, "NA", 0, "0"
FROM qryGraph00
WHERE NOT EXISTS (SELECT * FROM qryGraph00 WHERE Model="3" AND FNumber = Forms!frmDisplay.tbxFNumber)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top