Experts, please see the attached picture. I will go a long ways in explaining what i need. First of all i know that i cannot do what is in the picture, i just dont know how to structure the query, but let me explain what i need.
I have a form with two listviews. One listview displays company names and the other listview displays contacts associated with the selected company. So when a user selects a company in listview1, listview2 is populated with the associated contacts.
Contacts in the database are associated with a project by the contact id fields (ShipToID) and (SoldToID) in the "ProjectProfile" table.
The user can add, edit and remove a company. If they remove a company then all associated contacts will also be removed.
What i need to do is make sure that the company is not associated with any active projects before the company is removed. The listview.selectedItems(0).
name in the listview1 for the companies will be the companyID which is found in the "Contact" table.
So if that contact (based on the companyID) is found to be in a project profile (in either the SoldToID or ShipToID) i want to output those project names and display them to the user in a message box explaining that the company cannot be removed because it is associated with one or more active project profiles.
I am also open to any suggestions that would make for a better design of the tables to be more efficient or easier to use.