Solved

Filter Datatable by child datatable

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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