
Originally Posted by
daltman1967
Ok, here's the relevant table structure:
D_License:
Last_Name, First_Name, Date_Of_Birth, Phone_Number, Called,
Date_Called, Code
G_License:
Last_Name, First_Name, Date_Of_Birth, Phone_Number
There are other fields, but these are the only ones I'm concerned with at the moment.
Mr. Jones has taken a D_License class, but NOT the G_License class. Mr. Smith has taken BOTH the D_License class AND the G_License class.
The list should be of ALL people who have taken the D_License class, but NOT the G_License class. I'm using First_Name, Last_Name, and Date_Of_Birth to compare records, as "John Smith 10/02/1967" is different from "John Smith 01/02/1955"; the names are the same, but they're different people; I'm also using the information to provide DISTINCT records, as Mr. Jones may have taken two D_License classes.
I'm making two resulting listboxes from the data: Those who have been called, and those who have not.
The resulting lists should display something like this:
Last_Name First_Name Phone_Number Date_Called Called Code
Johnson Fred (305) 555-1212 01/17/12 Yes LM
Last_Name First_Name Phone_Number Date_Called Called Code
Smith John (305) 555-1212 ________ __ ____
etc.
I can then go through either list and select a name, then click a drop-down list of the call codes. When I do this, the On Change event of the drop down list goes through a vbcode process (a very simple one) and changes the data in D_License to reflect the change - today's date, "Yes" for called, and the call code.
As I said, only the Last_Name, First_Name, and Date_Of_Birth should be part of the "DISTINCT" query, otherwise the query would fail; however, the other data DOES need to be included....
I have a similar function to this D_not_G_Query that I was able to complete by writing a simple comparison, but within a single table. With that one, I was looking through D_License to see if Mr. Jones had taken the 24 hour class but NOT the 16 hour class.
To do this, I cycled through the list of ALL D_License records, and assigned the resulting First_Name, Last_Name, and Date_Of_Birth to local variables. I then loop through the variables to find duplicates.
If a duplicate is found (two classes taken), I set D_License!Include to equal 2; if not, I set it to 1. The resulting query was easy; display ONLY the records with a 1.
For the D_not_G_Query, I had hoped to possibly do the same; come up with the list, and then mark the D_License!Include to be 2 for the ones on the list, and 1 for the ones NOT on the list - and then the resulting query would be easy, as before. However, it seems that the JOIN is making this thing uneditable.
I hope this explains everything well enough. Perhaps I could run a second query -- select ALL records from D_License where they match the records found in D_not_G_Query. Any ideas, anyone?