Solved

Filter Datatable by child datatable

Posted on 2008-10-13
2
242 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 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

10 Experts available now in Live!

Get 1:1 Help Now