I have an Attendee combobox which is populated with all names from the People table, the only criteria is their role cannot be "dbadmin" (see below query). The Attendee combobox are people who go to scheduled events. Occasionally, we have a temp person as a fill-in for these events. I use VBA to add these temps to the People table, with a role of "(temp)"; I then re-query the combobox to get them to appear in the Attendee combobox for selection. I do not want these temps to appear when I am creating a new event or if I re-visit a previous event UNLESS they were an attendee at that event. If I re-visit an event in the db that they attended, I want them to appear in the combobox. I basically need to scan the people table, if their role is "temp", scan through attendance table and see if there is an attendance record for this event with their EmployeeID, if so they should be included in query. Also, the attendee combo is 2 column, 1st being ID, 2nd Name, bound to 1st)
1. Creating a new event, need to use "bob smith" as a temp fill-in
2. He is added to People table, with role of "(temp)", re-query combo and he is then selectable in my attendee combo
3. I navigate to create a new or re-visit an older record (which bob did not attend), "bob smith" should not appear
4. I revisit the new event from steps 1-2 and he is listed in the combo boxes.
When I select an Attendee from the combobox (as attending the event), a new record is created in the Attendance table (AttendanceID; EventID; EmployeeID).
Code:
People table fields:
EmployeeID
Name
Role
Attendance table fields:
AttendanceID
EventID
EmployeeID
Event table fields:
EventID
Date
Time
Scheduler (etc..)
Current query
Code:
SELECT People.ID, People.Name
FROM People
WHERE (Role<>"dbadmin")
ORDER BY People.Name;