Solved

Filter Datatable by child datatable

Posted on 2008-10-13
2
249 Views
Last Modified: 2012-06-27
i have a dataset that contains 4 tables

Companies
Contact
Quotes
QuoteDetails

all of the table have relations
Companies(UID) - Contacts(UID) 1 to many
Contact(UCID) - QUotes(UCID) 1 to many
Quotes(Quote_Number) - QuoteDetails(Quote_Number) 1 to many

the data on my form uses binding sources to display the data.

I am wanting to allow the user to filter the data by a number of different methods.

I can easliy filter the data by company name for instance bsCompanies.filter = "company like 'dir%' but how could i filter to bring back all the companies that have had a quote in the last 2 months for instance

I hope this makes sense

thanks

0
Comment
Question by:Marcusw
[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 Comments
 
LVL 4

Accepted Solution

by:
Mitzs earned 500 total points
ID: 22702443
I take it that only way to link company & Quote is through Contact and based on that assumption, once you have selected the company you can have an array of contact rows by filtering on company Id of the selected company.
You can then loop through the rows of contact  array and generate a list of contact Id's seperated by comma and then you can use this to get your quotes for all those contact Id's but limited by only 2 months.
dim filter1 = "[company Id] = 1234"  
dim sContactId as string
 For Each row As DataRow In DS("Contact").Select(filter1)
          scontactId = scontactid & row.Item("Contact Id").tostring & ","
    Next

bsQuote.filter = "[Contact Id] in ("  & scontactId & ") and QuoteDate > " &  DateAdd(DateInterval.Month,-2,today.Date)
0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22702610
are you using Typed Dataset? If Yes, I think you will get some methods generated automatically to the data.
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 explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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