Solved

Need some help with query design.

Posted on 2014-03-07
3
373 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
Comment Utility
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
Comment Utility
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
Comment Utility
You are welcome!

/gustav
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

12 Experts available now in Live!

Get 1:1 Help Now