Hello
I was trying to find a solution to my problem with combobox
Here is my problem. I have 2 combobox and I have created a realtionship between them, so the value of the second combo will depent on the selection of the first. Now my problem is how do I set the SelectedValue to the Organization_ID like I did with setting the DisplayMember to Organization_Name? Here is the code(I'm using access DB):
" Dim ds As New DataSet
Dim cmdString As String = "select * from tblOrganization"
Dim da As New OleDb.OleDbDataAdapter(cmdString, con)
da.Fill(ds, "tblOrganization")
cmdString = " select * from tblAccount"
da = New OleDb.OleDbDataAdapter(cmdString, con)
da.Fill(ds, "tblAccount")
Dim relation As New DataRelation("ArtAuth", _
ds.Tables("tblOrganization").Columns("Organization _ID"), _
ds.Tables("tblAccount").Columns("OrganizationID") _
)
ds.Relations.Add(relation)
cbOrg.DataSource = ds
cbOrg.DisplayMember = "tblOrganization.Organization_Name"
cbOrg.SelectedValue = "tblOrganization.Organization_ID"
cbAccount.DataSource = ds
cbAccount.DisplayMember = "tblOrganization.ArtAuth.AccountName"
cbAccount.ValueMember = "tblOrganization.ArtAuth.AccountID""
I was trying to find a solution to my problem with combobox
Here is my problem. I have 2 combobox and I have created a realtionship between them, so the value of the second combo will depent on the selection of the first. Now my problem is how do I set the SelectedValue to the Organization_ID like I did with setting the DisplayMember to Organization_Name? Here is the code(I'm using access DB):
" Dim ds As New DataSet
Dim cmdString As String = "select * from tblOrganization"
Dim da As New OleDb.OleDbDataAdapter(cmdString, con)
da.Fill(ds, "tblOrganization")
cmdString = " select * from tblAccount"
da = New OleDb.OleDbDataAdapter(cmdString, con)
da.Fill(ds, "tblAccount")
Dim relation As New DataRelation("ArtAuth", _
ds.Tables("tblOrganization").Columns("Organization _ID"), _
ds.Tables("tblAccount").Columns("OrganizationID") _
)
ds.Relations.Add(relation)
cbOrg.DataSource = ds
cbOrg.DisplayMember = "tblOrganization.Organization_Name"
cbOrg.SelectedValue = "tblOrganization.Organization_ID"
cbAccount.DataSource = ds
cbAccount.DisplayMember = "tblOrganization.ArtAuth.AccountName"
cbAccount.ValueMember = "tblOrganization.ArtAuth.AccountID""