Remplissage depuis selection combobox
Bonjour,
Malgre mes recherches sur internet, je n'arrive pas a remplir une combobox en fonction d'une autre combobox. Je m'explique: par exemple dans ma combobox 2 je selectionne le nom d'un client, dans la combobox 3 je voudrais toutes les commandes le concernant et dans les textbox je voudrais d'autres informations comme description et fournisseur.
En sachant que toutes ces informations viennent d'une table access.
Je sais pas si c'est tres clair, voici ce que j'qi deja fait mais ca ne fonctionne pas
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
Public Class NewTools
Dim cn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=ToolDatabaseVB_be.accdb")
Private Sub NewTools_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.XtblDepartmentsTableAdapter.Fill(Me.ToolDatabaseVB_beDataSet.xtblDepartments)
' remplissage combobox2
Dim cmd As New OleDbCommand("select distinct FITEM from Database1 Order by FITEM asc", cn)
cn.Open()
Dim da As New OleDbDataAdapter(cmd)
Dim UneTable As New DataTable
da.Fill(UneTable)
ComboBox2.DataSource = "UneTable"
ComboBox2.DisplayMember = "FITEM"
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
' remplissage combobox3
cn.Open()
Dim cmd As New OleDbCommand("select distinct ORDNO from Database1 where FITEM='" & ComboBox2.Text & "'", cn)
Dim da As New OleDbDataAdapter(cmd)
Dim UneTable As New DataTable
da.Fill(UneTable)
ComboBox3.DataSource = "UneTable"
ComboBox3.DisplayMember = "ORDNO"
'remplissage textbox
Dim dr As OleDbDataReader = cmd.ExecuteReader
While dr.Read()
TextBox4.Text = dr(26).ToString
TextBox5.Text = dr(11).ToString
TextBox6.Text = dr(31).ToString
End While
dr.Close()
cn.Close()
End Sub
End Class |
Merci d'avance pour vos reponses