Simply Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I accomplish the following:
I would like to learn how to check if a name has been selected more than one
time on a given day (since 1 person can be 2 places at the same time). I am
assuming I will have to build an event in BeforeUpdate of cboEmployee, but I
am not good at SQL.

This is my psuedo-SQL:
Select * from tblDatesAssigned
Where (the employee does not have a record with the same date as the current
record)

Table Structure:
tblDates.Date (PK) is linked to tblDatesAssigned.Date (FK), and
tblDatesAssigned.EmployeeID(FK) is linked to tblEmployee.EmployeeID (PK)

Thanks in advance!
 
Perhaps something along the lines of the following. It would have to be
requeried each time you changed records and each time you change the value
in the date control. Also, Since it would fail if the value in
theDateControl was null , I used NZ around the control reference to force
some value). Optionally, you could test for a null or invalid date and
change the comboboxes row source to just show all employees.


SELECT *
FROM tblDatesAssigned
Where EmployeeID Not IN
(Select EmployeeId
FROM tblDatesAssigned
WHERE [Date] = Nz(Forms![TheFormName]![TheDateControl],#1/1/9999#))
 
Back
Top