Bonjour,

J'ai cherché un peu partout sur le net et je ne parviens pas à trouver la réponse à une question bien simple : comment ajouter des éléments à un combobox? Voici mon code. Le problème porte sur l'élément "ctr_priority", et j'ai beau essayer les méthodes additem ou items.add, la réponse retournée par access est "méthode non supportée par cet objet".

Merci!

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'********************** Mise en Forme Controls **************

Private Sub M_control(frm As Form, rstT_Tampon2 As DAO.Recordset)

Dim i As Long
Dim haut As Long
Dim ctr_affaire(1 To 500) As Control
Dim ctr_month(1 To 500) As Control
Dim ctr_year(1 To 500) As Control
Dim ctr_priority(1 To 500) As Control
Dim a As Long

i = 1
haut = 200

rstT_Tampon2.MoveFirst

Do While Not rstT_Tampon2.EOF
    
    Set ctr_affaire(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, 1500, 300)
    Set ctr_month(i) = CreateControl(frm.Name, acTextBox, , "", "", 500, 500, 1500, 300)
    Set ctr_year(i) = CreateControl(frm.Name, acTextBox, , "", "", 500, 500, 1500, 300)
    Set ctr_priority(i) = CreateControl(frm.Name, acComboBox, , "", "", 500, 500, 1500, 300)
    
    
        If i > 2 Then
        If a <> Year(rstT_Tampon2.Fields(5).Value) Then
        haut = haut + 300
        End If
        End If
    
        ctr_affaire(i).Name = "Affaire_" & i
        ctr_month(i).Name = "Month_" & i
        ctr_year(i).Name = "Year_" & i
        ctr_priority(i).Name = "Priority_" & i
        
        ctr_affaire(i).Caption = rstT_Tampon2.Fields(8).Value
        ctr_affaire(i).Left = 100
        ctr_month(i).Left = 1300
        ctr_year(i).Left = 1600
        ctr_priority(i).Left = 2500
        
        ctr_affaire(i).Top = haut + i * 300
        ctr_month(i).Top = haut + i * 300
        ctr_year(i).Top = haut + i * 300
        ctr_priority(i).Top = haut + i * 300
        
        ctr_month(i).Width = 250
        ctr_year(i).Width = 600
        
        ctr_month(i).DefaultValue = Month(rstT_Tampon2.Fields(5).Value)
        ctr_year(i).DefaultValue = Year(rstT_Tampon2.Fields(5).Value)
        
        ctr_priority(i).contenu = "AA"
        
        ctr_priority(i).Items.Add ("Normale")
        'ctr_priority(i).AddItem "Haute"
        'ctr_priority(i).AddItem "Basse"
        
        a = Year(rstT_Tampon2.Fields(5).Value)

        i = i + 1

    rstT_Tampon2.MoveNext
Loop

End Sub