?
Solved

Filter Datatable by child datatable

Posted on 2008-10-13
2
Medium Priority
?
255 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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 …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

741 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