return values that don't exist

beefwellington

Registered User.
Local time
Today, 11:00
Joined
Jul 27, 2009
Messages
14
I have two tables, one that holds a list of times (8AM-5PM) to use as a rowsource for comoboxes and a table to log appointments.

I'm trying to do the following: The user selects and Advisor then a Date. Then the RowSource for the Time of the appointment changes to only show the times available for that day.

For the RowSource I have the following code and SQL:
Code:
Me.ddlAppointmentTime.RowSource = "SELECT Time FROM TimeList WHERE NOT EXISTS(SELECT Appointment_Time FROM AppointmentLog WHERE USPAdvisor_ID = " & Me.ddlUSPAdvisor.Value & " AND Appointment_Date = #" & Me.txtAppointmentDate.Value & "#)"

on days where an Advisor has NO appointments at all, all the times show up. On a day an Advisor DOES have an appointment, no times show up. I figure I must have the SQL a little off. Can someone help me figure out what I'm doing wrong?
 
I fixed my Query by changing "NOT EXISTS" to "Time <>". I wanted to post this in case anyone searches the forum for the same problem I was having.

Code:
Me.ddlAppointmentTime.RowSource = "SELECT Time FROM TimeList WHERE Time <> (SELECT Appointment_Time FROM AppointmentLog WHERE USPAdvisor_ID = " & Me.ddlUSPAdvisor.Value & " AND Appointment_Date = #" & Me.txtAppointmentDate.Value & "#)"
 

Users who are viewing this thread

Back
Top Bottom