Message d'erreur

Bonjour,

J'ai une erreur que je n'arrive pas a trouver malgré toute les recherches, sur la ligne;

MultiPage1.Pages(1).Controls("TextBox" & k) = .Cells(lig, k)

Message: Erreur d'exécution 2147352571 (80020005):

Impossible de définir la propriété Value. Le type ne correspond pas.

Mon code complet

Private Sub UserForm_Initialize()

 MultiPage1.Pages(0).Visible = True:
 Me.MultiPage1.Value = 0 ' Activer la page d'accueil
 Label22.Caption = MultiPage1.SelectedItem.Caption

   Dim Rep, NomFic, sheetsUse As String
   Dim i, j As Integer
   Dim tableau() As String
        Me.MultiPage1.Value = 0
   If choose Then

   Rep = "J:\Réalisateur\"
   GoTo suite1
          Else
   Rep = "J:\acteur\"
   End If

   With Feuil3 'Feuille "Etat Civil"

 lig = Application.Match(NomRéalisateur, .[B1:B65000], 0)

 If Not IsNumeric(lig) Then GoTo suite1
     Me.Label5.Caption = NomRéalisateur
     For k = 1 To 8
     MultiPage1.Pages(1).Controls("TextBox" & k) = .Cells(lig, k)
     Next

     If .Range("G" & lig).Value <> "" Then
       MultiPage1.Pages(1).TextBox7.Value = .Range("G" & lig).Value 'Décédé le
       MultiPage1.Pages(1).Label14.Caption = .Range("h" & lig).Value 'Décédé à l'âge
       MultiPage1.Pages(1).Label23.Caption = .Range("l" & lig).Value 'Il aurait l'âge
     Else
       MultiPage1.Pages(1).TextBox7.Value = "Non décédé"
     End If

       MultiPage1.Pages(1).TextBox8.Value = .Range("B" & lig).Value 'Nom usuel
       MultiPage1.Pages(1).TextBox2.Value = .Range("i" & lig).Value 'Nom naissance
       MultiPage1.Pages(1).Label16.Caption = .Range("j" & lig).Value & " (ième ligne)" 'N° de ligne

   Label16.Caption = " La fiche se situe sur la ...." & " " & Label16.Caption & " de la feuille BdD Acteurs "

 NomFic = Label5.Caption 'Pour la photo acteur
 End With

 suite1:
 With Feuil7 'Feuille 
    'ici remplissage biographie
 lig = ""
 lig = Application.Match(Label5, .[A1:A65000], 0)
 If Not IsNumeric(lig) Then GoTo suite2

 MultiPage1.Pages(2).TextBox9 = .Cells(lig, 2)
 MultiPage1.Pages(2).TextBox9.SelStart = 0

 MultiPage1.Pages(2).Label18.Caption = .Range("c" & lig).Value & " (ième ligne)" 'N° de ligne
   Label18.Caption = " La fiche se situe sur la ...." & " " & Label18.Caption
 End With

 suite2:
 With Feuil5 

 MultiPage1.Pages(3).Label20.Caption = .Range("bq" & lig).Value & " (ième ligne)" 'N° de ligne
 Label20.Caption = " La fiche se situe sur la ...." & " " & Label20.Caption

 lig = Application.Match(NomRéalisateur, .[A1:A65000], 0)
 If Not IsNumeric(lig) Then GoTo suite3
 For k = 2 To 68
 ListBox1.AddItem .Cells(1, k)
 ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(lig, k)
 Next
 End With

 suite3:
 With Feuil9 

 MultiPage1.Pages(4).Label21.Caption = .Range("ef" & lig).Value & " (ième ligne)" 'N° de ligne
 Label21.Caption = " La fiche se situe sur la ...." & " " & Label21.Caption

 lig = Application.Match(NomRéalisateur, .[A1:A65000], 0)
 If Not IsNumeric(lig) Then GoTo suite5
 i = -1
 For k = 2 To 134 Step 2
 ListBox2.AddItem .Cells(1, k): i = i + 1
 ListBox2.List(i, 1) = .Cells(lig, k)
 ListBox2.List(i, 2) = .Cells(lig, k + 1)
 Next

 End With
 GoTo suite8

 suite4:
 With Feuil4 

 lig = Application.Match(NomRéalisateur, .[B1:B65000], 0)
 If Not IsNumeric(lig) Then GoTo suite5

     Me.Label5.Caption = NomRéalisateur
     For k = 1 To 6
     'MultiPage1.Pages(1).Controls("TextBox" & k) = .Cells(lig, k) 'Métier
     Next

     If .Range("G" & lig).Value <> "" Then
     MultiPage1.Pages(1).TextBox7.Value = .Range("G" & lig).Value 'Décédé le
     MultiPage1.Pages(1).Label14.Caption = .Range("h" & lig).Value 'Décédé à l'âge
     MultiPage1.Pages(1).Label23.Caption = .Range("l" & lig).Value 'Il aurait l'âge

     Else

     MultiPage1.Pages(1).TextBox7.Value = "Non décédé"
     End If

       MultiPage1.Pages(1).TextBox8.Value = .Range("B" & lig).Value 'Nom usuel
       MultiPage1.Pages(1).TextBox2.Value = .Range("i" & lig).Value 'Nom naissance
       MultiPage1.Pages(1).Label16.Caption = .Range("j" & lig).Value & " (ième ligne)" 'N° de ligne

   Label16.Caption = " La fiche se situe sur la ...." & " " & Label16.Caption & " de la feuille BdD Noms "
     NomFic = Label5.Caption 'Pour la photo réalisateur
       End With

 suite5:

 With Feuil6

 MultiPage1.Pages(3).Label20.Caption = .Range("bq" & lig).Value & " (ième ligne)" 'N° de ligne
 Label20.Caption = " La fiche se situe sur la ...." & " " & Label20.Caption

 lig = Application.Match(NomRéalisateur, .[A1:A65000], 0)
 If Not IsNumeric(lig) Then GoTo suite6
 For k = 2 To 68
 ListBox1.AddItem .Cells(1, k)
 ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(lig, k)
 Next
 End With

 suite6:
 With Feuil8 

 lig = ""
 lig = Application.Match(Label5, .[A1:A65000], 0)
 If Not IsNumeric(lig) Then GoTo suite7

 MultiPage1.Pages(2).TextBox9 = .Cells(lig, 2)
 MultiPage1.Pages(2).TextBox9.SelStart = 0

 MultiPage1.Pages(2).Label18.Caption = .Range("c" & lig).Value & " (ième ligne)" 'N° de ligne
   Label18.Caption = " La fiche se situe sur la ...." & " " & Label18.Caption

 End With

 suite7:
 With Feuil10 

 MultiPage1.Pages(4).Label21.Caption = .Range("ef" & lig).Value & " (ième ligne)" 'N° de ligne
 Label21.Caption = " La fiche se situe sur la ...." & " " & Label21.Caption

 lig = Application.Match(NomRéalisateur, .[A1:A65000], 0)
 If Not IsNumeric(lig) Then GoTo suite8
 i = -1
 For k = 2 To 134 Step 2
 ListBox2.AddItem .Cells(1, k): i = i + 1
 ListBox2.List(i, 1) = .Cells(lig, k)
 ListBox2.List(i, 2) = .Cells(lig, k + 1)
 Next

 End With

 suite8:
 Image1.Visible = True
 If Dir(Rep & NomFic & ".jpg") <> "" Then
     Image1.Picture = LoadPicture(Rep & NomFic & ".jpg")
 Else
     Image1.Picture = LoadPicture
 End If

 End Sub

et dans un module il y a

Public NomRéalisateur As String

Je vous remercie d'avance

Cordialement

Max

Bonjour

Dans un UserForm, les controles sont numérotés de 1 à n quellle que soit la page sur laquelle ils sont.

Essaie donc en simplifiant ce type d'instruction :

MultiPage1.Pages(1).Controls("TextBox" & k) = .Cells(lig, k)

et en mettant à la place :

Controls("TextBox" & k) = .Cells(lig, k)

Bye !

Bonjour gmb

Je te remercie mais non toujours la même erreur

@+

Max

Joins ton fichier, on regardera ça de plus près.

Bye !

Re,

J'ai mis un "On Error Resume Next" et sa fonctionne

je te remercie

Bye !

Rechercher des sujets similaires à "message erreur"