Hi,
I am trying to write a query that will look first in tblSealStripData to see if there is a date in the NextD field and if there is give the results from that record but if that field is empty then look in tblPEMAC in the DateStart field and give the results from that record in the table.
I have tried a union query and this is the first time I have tried to use one of these.
I have 2 queries that independently give the result for each table but would like to combine them into one so that I can use this to populate a subform.
Any help would be great.
Regards,
I am trying to write a query that will look first in tblSealStripData to see if there is a date in the NextD field and if there is give the results from that record but if that field is empty then look in tblPEMAC in the DateStart field and give the results from that record in the table.
I have tried a union query and this is the first time I have tried to use one of these.
I have 2 queries that independently give the result for each table but would like to combine them into one so that I can use this to populate a subform.
Code:
SELECT DISTINCTROW tblSealStripData.PEMAC, tblSealStripData.Description, tblSealStripData.Interval, Max(tblSealStripData.NextD) AS MaxOfNextD, tblSealStripData.Location
FROM tblSealStripData
GROUP BY tblSealStripData.PEMAC, tblSealStripData.Description, tblSealStripData.Interval, tblSealStripData.Location
HAVING (((Max(tblSealStripData.NextD)) Between Date() And Date()+20))
UNION
SELECT tblPEMAC.PEMAC, tblPEMAC.Description, tblPEMAC.Interval, tblPEMAC.DateStart, tblPEMAC.Location
FROM tblPEMAC
Any help would be great.
Regards,
Last edited: