1

EDITED: Please look again.

`qryHistoryTimeLog`   /   `qryHistoryAppt`
34 , 03/07/17 , 170   /   34 , 01/13/17 , Checked Out and Complete
34 , 03/28/17 , 125   /   34 , 02/09/17 , Checked Out and Complete
34 , 04/28/17 , 140   /   34 , 03/07/17 , Checked Out and Complete
34 , 05/19/17 ,  85   /   34 , 03/28/17 , Checked Out and Complete
34 , 08/05/17 ,  75   /   34 , 04/28/17 , Checked Out and Complete
34 , 08/24/17 ,  65   /   34 , 05/19/17 , Checked Out and Complete
                      /   34 , 06/09/17 , Checked Out and Complete
                      /   34 , 08/05/17 , Checked Out and Complete
                      /   34 , 08/24/17 , Checked Out and Complete

The query qryHistoryAppt is pulling from the software's database table of all appointments that are for client #34 and are "Checked Out and Complete".

The query qryHistoryTimeLog is pulling from my table of entered information from the client's appointment.

I am looking for the appointment dates that have been Checked Out and Completed, but have not yet been entered into my tblTimeLog so I know which appointment cards need to be pulled and entered.

`qryTesting`
34 , 01/13/17
34 , 02/09/17
34 , 06/09/17

I also should add, that I am passing along the client number through this new query. So that when I run the query I can enter which client's appointments I am looking for.

ANSWERED:

SELECT DISTINCT qryHistoryAppt.petId, 
                qryHistoryAppt.petName, 
                qryHistoryAppt.cstLName, 
                qryHistoryAppt.aptDate
FROM qryHistoryAppt LEFT JOIN qryHistoryTimeLog ON 
    (qryHistoryAppt.petId = qryHistoryTimeLog.PetID) AND 
    (qryHistoryAppt.aptDate = qryHistoryTimeLog.ApptDate)
WHERE (((qryHistoryAppt.petId)=[]) AND
       ((qryHistoryTimeLog.ApptDate) Is Null));

2 Answers2

1

Simply LEFT JOIN on petId and ApptDate. Right now you are only matching against petID.

SELECT DISTINCT h.petId, h.aptDate
FROM qryHistoryAppt h
LEFT JOIN qryHistoryTimeLog l 
   ON h.petId = l.PetID AND h.aptDate = l.ApptDate
WHERE (((l.PetID) IS NULL));
Parfait
  • 104,375
  • 17
  • 94
  • 125
0
SELECT qryHistoryAppt.petId, 
         qryHistoryAppt.petName, 
         qryHistoryAppt.aptDate
FROM qryHistoryAppt LEFT JOIN qryHistoryTimeLog ON qryHistoryAppt.petId = qryHistoryTimeLog.PetID
WHERE qryHistoryTimeLog.PetID is null
GROUP BY qryHistoryAppt.petId, qryHistoryAppt.petName, qryHistoryAppt.aptDate
HAVING (((qryHistoryAppt.petId)=[]))
ORDER BY qryHistoryAppt.aptDate DESC;
Max08
  • 955
  • 1
  • 7
  • 16