Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Filter Datatable by child datatable

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
Marcusw
Asked:
Marcusw
1 Solution
 
MitzsCommented:
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
 
SameerJagdaleCommented:
are you using Typed Dataset? If Yes, I think you will get some methods generated automatically to the data.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now