Solved

Need some help with query design.

Posted on 2014-03-07
3
380 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
  • 2
3 Comments
 
LVL 49

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 49

Expert Comment

by:Gustav Brock
ID: 39913483
You are welcome!

/gustav
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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 …

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now