Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need some help with query design.

Posted on 2014-03-07
3
Medium Priority
?
413 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 52

Accepted Solution

by:
Gustav Brock earned 2000 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 52

Expert Comment

by:Gustav Brock
ID: 39913483
You are welcome!

/gustav
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

824 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