Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query that does not show previously selected items

Status
Not open for further replies.

poporacer

Programmer
Oct 2, 2007
53
US
I have a form that is used to input staff data. This form is opened from a form that tracks incidents. I have 3 associated tables. The first table (tblStaff)has the information on staff. The second table (tblIncidents) contains the relevant information to each incident. And the third table (tblStaffIncident)contains the information specific to the staff member in the incident. I have a function that pulls a global variable to hold the current incident number (getCurrentLog()) this is what happens, you select an incident from frmIncident and then click on a button to add staff to the incident. A form, frmAddStaff opens up and there is a combo box to select staff that are currently in the database. What I want this combobox to do is populate with all the records from tblStaff but to exclude staff that are already in the selected incident so that there is no way for duplicate staff entries. Each Staff has a unique ID number (CDCNum)
So I need a query that is somewhat like this:

SELECT * from tblStaff
where tblStaff.CDCNum<> (tblStaffIncident.CDCNum and LogNum= getCurrentLog()

So I need all the staff from tblStaff that do not have an entry in tblStaffIncident with a matching log number to getCurrentLog()

I am sure this is probably as clear as mud but hopefully you understand what I am trying to achieve.
 
SELECT * FROM tblStaff WHERE CDCNum Not In (SELECT CDCNum FROM tblStaffIncident WHERE LogNum=getCurrentLog())


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top