Arg81
Well-known member
I'm either having a blonde day or a bad day, I haven't decided yet...
I use a global dataset to store all of my customer information so that all forms access it without having to load the data everytime. This works great.
I load all of the tableAdapters on my main menu and then set varDsCustomer = me.dsCustomer
The 3 tables are Customer, CustomerSite and CustomerContact
I then have a search form. By typing in a string into a box and searching, it will list all matching customers in the first combobox. This is done with;
[/COLOR][/SIZE]
However, I want the 2nd combobox to only show Sites for the selected customer (on the press of a button). I've read that I need to set the display member and value member to that of my DataSet Relation, and I have done so using;
But the first site(s) in the Site table are listed. This is because my Customer and customerSite tables are linked by CustomerID. For some reason, when the Customer combobox is filled, the CustomerID seems to be staying at "1".
How do I use the CustomerID from the Customer combobox (so when the customer changes, so does the ID obviously) to then sort the 2nd combobox?
Or is this not possible when using Global DataSets this way?
[/SIZE]
I use a global dataset to store all of my customer information so that all forms access it without having to load the data everytime. This works great.
I load all of the tableAdapters on my main menu and then set varDsCustomer = me.dsCustomer
The 3 tables are Customer, CustomerSite and CustomerContact
I then have a search form. By typing in a string into a box and searching, it will list all matching customers in the first combobox. This is done with;
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] expCustName = [/SIZE][SIZE=2][COLOR=#a31515]"CustomerName LIKE '"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtSearchCust.Text & [/SIZE][SIZE=2][COLOR=#a31515]"%'"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sortCustName = [/SIZE][SIZE=2][COLOR=#a31515]"CustomerName ASC"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].cboCustomer
.DataSource = varDSCustomer.Tables([/SIZE][SIZE=2][COLOR=#a31515]"Customer"[/COLOR][/SIZE][SIZE=2]).Select(expCustName, sortCustName)
.DisplayMember = [/SIZE][SIZE=2][COLOR=#a31515]"CustomerName"
[/COLOR][/SIZE][SIZE=2].ValueMember = [/SIZE][SIZE=2][COLOR=#a31515]"CustomerID"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]
However, I want the 2nd combobox to only show Sites for the selected customer (on the press of a button). I've read that I need to set the display member and value member to that of my DataSet Relation, and I have done so using;
VB.NET:
[/COLOR][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2][COLOR=#000000].cboCustomerSite[/COLOR]
.DataSource = varDSCustomer
.DisplayMember = [/SIZE][SIZE=2][COLOR=#a31515]"Customer.Customer_CustomerSite.CustomerSiteName"
[/COLOR][/SIZE][SIZE=2].ValueMember = [/SIZE][SIZE=2][COLOR=#a31515]"Customer.Customer_CustomerSite.CustomerSiteID"
[/COLOR][/SIZE][SIZE=2].Focus()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]
But the first site(s) in the Site table are listed. This is because my Customer and customerSite tables are linked by CustomerID. For some reason, when the Customer combobox is filled, the CustomerID seems to be staying at "1".
How do I use the CustomerID from the Customer combobox (so when the customer changes, so does the ID obviously) to then sort the 2nd combobox?
Or is this not possible when using Global DataSets this way?
[/SIZE]