Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need some help with query design.

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

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 51

Expert Comment

by:Gustav Brock
ID: 39913483
You are welcome!

/gustav
0

Featured Post

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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 …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

664 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