Bonjour;

Suite à mon premier post, j'ai complété le code afin de disposer des seules valeurs pertinentes selon que l'utilisateur sélectionne, à la combobox1, le libellé 1 ou 2.

J'ai donc rajouter :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
        ComboBox2.SelectedIndex = -1
        ComboBox2.Items.Clear()
Mon code est le suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Imports System.Data.OleDb
 
Public Class Form1
    Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Users\...\bdd.accdb;Persist Security Info=False;"
    Dim MyConn As OleDbConnection
    Dim da As OleDbDataAdapter
    Dim ds As DataSet
    Dim tables As DataTableCollection
    Dim source1 As New BindingSource
 
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Items.Add("LIBELLE 1")
        ComboBox1.Items.Add("LIBELLE 2")
    End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox2.SelectedIndex = -1
        ComboBox2.Items.Clear()
        If ComboBox1.SelectedItem= "LIBELLE 1" Then
            ComboBox2.Items.Add("LIBELLE A")
            ComboBox2.Items.Add("LIBELLE B")
            ComboBox2.Items.Add("LIBELLE C")
        ElseIf ComboBox1.SelectedItem = "LIBELLE 2" Then
            ComboBox2.Items.Add("LIBELLE D")
            ComboBox2.Items.Add("LIBELLE E")
            ComboBox2.Items.Add("LIBELLE F")
        End If
    End Sub
Il fonctionne mais j'ai besoin d'une 3ième combobox liée à 2 tables de ma bdd access lorsque par exemple l'utilisateur sélectionne LIBELLE E ou LIBELLE F

J'aimerai pouvoir remplacer par exemple LIBELLE XXX par des valeurs issues de ma bdd access.

Le code est le suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        ComboBox3.SelectedIndex = -1
        ComboBox3.Items.Clear()
 
        If ComboBox1.SelectedItem = "LIBELLE 2" And ComboBox2.SelectedItem = "LIBELLE E" Then
            ComboBox3.Items.Add("LIBELLE XXX")
ElseIf
If ComboBox1.SelectedItem = "LIBELLE 2" And ComboBox2.SelectedItem = "LIBELLE F" Then
            ComboBox3.Items.Add("LIBELLE YYY")
End if

J'ai lu ici et la et je pense qu'il est peut être nécessaire d’intégrer

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
  ComboBox3.DataSource = DataSet.Tables("NomDeMaTable")
  ComboBox3.DisplayMember = "NomDeLaColonneDeMaTable"
mais j'avoue être perdu ... un petit coup pouce en ce dimanche pluvieux serait cool

Merci beaucoup