I have a query where I am trying to list 2 employees names each for a different criteria\reason (each query result should list 2 employee names). One of the ID numbers is for an Attendee of an event (working fine), the other ID is the scheduler of that event (not working). I'm not sure how to go about adding the scheduler.
The scheduler ID is stored in Events.ScheduledBy and the employee ID is Security.ID and name Security.LastName. I can do this with a dlookup but I'd prefer to not use it.
Original query (without the ScheduledBy part.
Code:
SELECT Security.ID, Events.ID, Security.FirstName, Security.LastName, Events.EventDate
FROM Security, Events, Attendance
WHERE ((Events.EventDate = txtSearch.Value) AND (Events.ID = Attendance.EventID) AND (Attendance.EmployeeID = Security.ID));
I tried this, but then it only lists events where the attendee and scheduler is the same person. If I use just Events.ScheduledBy in my SELECT statement, it properly pulls the ID of the scheduledby person, but I want it to pull the name based on that ID. But I need the query to differentiate between the attendee and scheduledby person.
Code:
SELECT Security.ID, Events.ID, Security.FirstName, Security.LastName, Events.EventDate, Security.LastName
FROM Security, Events, Attendance
WHERE ((Events.EventDate = txtSearch.Value) AND (Events.ID = Attendance.EventID) AND (Attendance.EmployeeID = Security.ID) And (Events.ScheduledBy = Security.ID));
This provides the result I want, but with DLookUp (if it helps you understand my issue)
Code:
SELECT Security.ID, Events.ID, Security.FirstName, Security.LastName, Events.EventDate, DLookUp("[LastName]","Security","[ID]=" & [Events].[ScheduledBy]) As Scheduler
FROM Security, Events, Attendance
WHERE ((Events.EventDate = txtSearch.Value) AND (Events.ID = Attendance.EventID) AND (Attendance.EmployeeID = Security.ID));