Solved

Need some help with query design.

Posted on 2014-03-07
3
398 Views
Last Modified: 2014-03-07
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.screen shot
0
Comment
Question by:Basicfarmer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 39913181
Remove the join to SoldToID.
Drag and drop once more table Contact on the pane. It will be labeled Contact_1.
Join ID from this to SoldToID.

/gustav
0
 

Author Closing Comment

by:Basicfarmer
ID: 39913194
WOW! thanks for the super fast response. I had no idea that was possible. Worked exactly as i needed it to.
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 39913483
You are welcome!

/gustav
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question