I have a form that has 2 combo boxes and a checkedlistbox. Combo1 contains a position number,combo 2 contains positions. When the user selects a pos no it populates combo2 with the pos desc and then lists responsibilites for that position in the checkedlistbox. When I select another pos no or pos desc i want to clear the checkedlistbox and repopulate it with the responsibilities of the new pos. Everything i have tried has resulted in an error.
Any suggestions please, as i am very new at this I am probably doing something majorally wrong.
Any suggestions please, as i am very new at this I am probably doing something majorally wrong.
Code:
Private Sub CboPosDesc_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboPosDesc.SelectedIndexChanged
If CboPosDesc.DisplayMember = "jobname" Then
If CboPosDesc.ValueMember = "post_ref" Then
If CboPosDesc.SelectedValue > 0 Then
CboPosition.SelectedValue = CboPosDesc.SelectedValue
filldelegations()
End If
End If
End If
End Sub
Private Sub filldelegations()
Dim strPost As String = CboPosition.Text
Dim cnposdel As New SqlConnection(connectionString)
Dim ssqlposdel As String = "SELECT DISTINCT t1.del_code, t1.del_code + ' ' + descript as xdesc FROM coffsdelegation_position t1 join coffsdelegation_type t2 on t1.del_code = t2.del_code where pos_ref = '" & strPost & "'"
Dim daptposdel As New SqlDataAdapter(ssqlposdel, cnposdel)
cnposdel.Open()
daptposdel.Fill(dsposdel, "jobpost")
fillCLBPosDel()
CLBPosDel.SelectedIndex = -1
If cnposdel.State = 1 Then cnposdel.Close()
cnposdel = Nothing
dsposdel.Dispose()
daptposdel.Dispose()
End Sub
Private Sub fillCLBPosDel()
CLBPosDel.DataSource = dsposdel.Tables("jobpost").DefaultView
CLBPosDel.DisplayMember = "xdesc"
CLBPosDel.ValueMember = "del_code"
End Sub
Private Sub CLBDelegations_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CLBDelegations.SelectedIndexChanged
End Sub