DerekMcDonald
Technical User
Hi! This would seem to be a pretty common query, but I can't find many helpful answers on how to set it up. Please bear with me and read on:
I've got a contacts database. Table 1 holds the contacts names and addresses. Table 3 holds the contact types (Board Member, Donor, Ex-Staff, etc.), and types can be added and deleted through a form. Table 2 links tables 1 and three together via the primary key. The user can thus choose multiple types for each contact on a form with a combo box.
Now, I'm trying to base a query on a form where the user can select all contacts where type = a AND b AND c. So the user can print a list of contacts who are Donors AND Ex-Staff.
I've set up a form where the user can run a query to find all contacts based on the values in up to three combo boxes. The values of the combo boxes are sent to a query based on the link table, returning all records where the TYPE's primary key equals the keys in the form's combo boxes. Then a subquery is run on the first query to find the duplicate values of the contact's primary key. This query is set to return the top value, in theory weeding out the contacts who return only two duplicates when three combo boxes on the form were filled.
And this works, except for the following situation. If three combo boxes are filled on the form (Find all CONTACTS Where TYPE is like A, B and C) but no contacts in the database match the criteria, a list of contacts is returned where the contacts match only two of the criteria, and the user has no way of knowing that the returns don't meet all the criteria.
Thanks for reading. I've been trying to figure this out for months- it's my holy grail. Any help would be greatly appreciated!
I've got a contacts database. Table 1 holds the contacts names and addresses. Table 3 holds the contact types (Board Member, Donor, Ex-Staff, etc.), and types can be added and deleted through a form. Table 2 links tables 1 and three together via the primary key. The user can thus choose multiple types for each contact on a form with a combo box.
Now, I'm trying to base a query on a form where the user can select all contacts where type = a AND b AND c. So the user can print a list of contacts who are Donors AND Ex-Staff.
I've set up a form where the user can run a query to find all contacts based on the values in up to three combo boxes. The values of the combo boxes are sent to a query based on the link table, returning all records where the TYPE's primary key equals the keys in the form's combo boxes. Then a subquery is run on the first query to find the duplicate values of the contact's primary key. This query is set to return the top value, in theory weeding out the contacts who return only two duplicates when three combo boxes on the form were filled.
And this works, except for the following situation. If three combo boxes are filled on the form (Find all CONTACTS Where TYPE is like A, B and C) but no contacts in the database match the criteria, a list of contacts is returned where the contacts match only two of the criteria, and the user has no way of knowing that the returns don't meet all the criteria.
Thanks for reading. I've been trying to figure this out for months- it's my holy grail. Any help would be greatly appreciated!