473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Bindingsource Filter with multiple values

I have a junction table for instance 1 service can have many contacts - using a composite key junction table.

what i want to do is to filter all the contacts that belong to the service using the junction table that includes just PK to service and PK to contact as a composite key.

I used this code

Expand|Select|Wrap|Line Numbers
  1.  'set up the agency binding source
  2.             With serviceBindingSource
  3.                 .DataSource = aDataSet
  4.                 .DataMember = "Service"
  5.                 .Filter = "Agency_ID = " & CInt(CurrentAgencyID)
  6.             End With
  7.  
  8.             'set up the offer binding source
  9.             With offerBindingSource
  10.                 .DataSource = aDataSet
  11.                 .DataMember = "Offer"
  12.                 .Filter = "Service_ID = " & Me.serviceBindingSource.Current("Service_ID").ToString
  13.             End With
  14.  
  15.             'set up the contactbinding source
  16.             With contactBindingSource
  17.                 .DataSource = aDataSet
  18.                 .DataMember = "Contact"
  19.                 .Filter = "Contact_ID = " + offerBindingSource.Current("Contact_ID").ToString
  20.             End With
  21.  
  22.             With Me.cboContact
  23.                 .DataSource = contactBindingSource
  24.                 .DisplayMember = "C_Name"
  25.                 .ValueMember = "Contact_ID"
  26.                 .DataBindings.Add("text", contactBindingSource, "C_Name", False, DataSourceUpdateMode.Never)
  27.             End With
  28.  
The problem is i get all the contact ids that are in the junction table for instance 3 then i want to filter those 3 contact ids in the contact bindingsource.

This seems to work with the = but it only filters the first record it finds in the junction table not all the "3" records that belong.

I tried using the IN but it still does the same thing.

Is there a way to use a for next to filter it to how many records of contacts belong to the services using the junction table that has a composite key for contact_id and services_id.

any help is appreciated

Okay its fixed

Expand|Select|Wrap|Line Numbers
  1. If offerBindingSource.Count <> 0 Then
  2.             'genius at work
  3.             Me.offerBindingSource.MoveFirst()
  4.             Dim count As Integer = Me.offerBindingSource.Count
  5.             count -= 1
  6.             'Dim IDArray(count) As String
  7.             Dim query As String = ""
  8.             For i As Integer = 0 To count
  9.                 query += "'" + Me.offerBindingSource.Current("Contact_ID").ToString + "'"
  10.                 If i <> count Then
  11.                     query += ","
  12.                 End If
  13.                 Me.offerBindingSource.MoveNext()
  14.             Next
  15.             contactBindingSource.Filter = "Contact_ID IN (" + query + ")"
  16.         End If
  17.  
pretty much had to think like a genius
Sep 23 '08 #1
0 3489

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: David McCrory | last post by:
Does anyone have a good example of using the Find() or Filter() methods of the BindingSource. I am binding to an array of objects and not having any luck getting these functions to work. ...
1
by: Leonardo | last post by:
Hi. I'm trying to build my first application with database access using VB 2005. I'm a VB 6 programmer and learning everything again has been challenging. I managed to write a code using some tips...
3
by: mafandon | last post by:
Is there a way to perform a bindingsource.filter on multiple inputs? For example: I would like the user to be able to put something like <Smith, Jones, Gates> into a textbox and have the...
1
by: mafandon | last post by:
Is it possible to filter a bindingsource twice? If I want to filter on gender, and filter on zip codes - can you do that with a bindingsouce.filter method? It always filters on the last filter...
4
by: michael sorens | last post by:
I have successfully bound an XmlDocument to a DataGridView but all fields seem to be strings. I want to retrofit appropriate datatypes on some of the fields. Let me take this in 2 parts. Part...
0
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have noticed the following behavior, which I believe is 'wrong'. I have a BindingSource that I am using to populate a datagrid, and I am using a DataView as the BindingSource.DataSource,...
2
nev
by: nev | last post by:
Does anyone know how to do that? In my real project actually, I filter on two fields like this... bindingsource.filter = "col1='" & var1 & "' AND col2='" & var2 & "'" wherein var1 or var2 may...
0
nev
by: nev | last post by:
Hello all. I would like to place code when bindingsource is being filtered. I have tried placing it in the positionchanged and listchanged event. But, when I try to filter the bindingsource, it...
1
by: =?Utf-8?B?Rm9lZg==?= | last post by:
I have a BindingSource with an underlying table with two primary keys. To set the position with one primary key works fine as shown in the code snippet below: Dim index As Integer =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.