Bonjour tout le monde,

à partir du form load, j'appelle une procédure appelée AfficherEnregistrements :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
Private Sub Form_Load()
    Dim NomFichier As String
    'si le dernier caractère de App.Path = "\" alors NomFichier = A
    NomFichier = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\") & "Contenu.mdb"
    If Not BDConnecter(NomFichier) Then
        MsgBox "Echec de connexion à la base de données" & vbCrLf & _
            NomFichier, vbCritical, Me.Caption
        Unload Me
        Exit Sub
    End If
    RemplirChoix
    AfficherEnregistrements
End Sub
J'ai à chaque fois ce message d'erreur :

Procédure ou function non définie
Voici ma procédure :

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
Private Sub AfficherEnregistrements(Optional ByVal IndiceMiseAJour As Integer = -1)
'If rsTable.BOF Or rsTable.EOF Then au cas où on ajoute un enregistrement avant le tout premier ou après le tout dernier enregistrement
'ça sert surtout à ajouter un enregistrement, l'ajout se fait après le dernier, on est alors en EOF
'On met les champs à rien pour pouvoir y indiquer une nouvelle entrée
    If rsTable.BOF Or rsTable.EOF Then
        If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampRecette) Then textChamp(ChampRecette).Text = ""
        'If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampPrenom) Then textChamp(ChampPrenom).Text = ""
        'If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampAdresse) Then textChamp(ChampAdresse).Text = ""
        'If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampLocalite) Then comboChamp(ChampLocalite).ListIndex = -1
    Else
        If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampRecette) Then textChamp(ChampRecette).Text = rsTable("nom") & " " & rsTable("prix")
        'If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampPrenom) Then textChamp(ChampPrenom).Text = "" & rsTable("prenom")
        'If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampAdresse) Then textChamp(ChampAdresse).Text = "" & rsTable("adresse")
        'If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampLocalite) Then BDSelectionnerParId rsTable("ref_localite"), comboChamp(ChampLocalite)
    End If
    AfficherNavigation False
End Sub
Je pense que c'est à cause du paramètre que je ne passe pas mais mon Prof a exactement le même code et chez lui ça fonctionne.

Sauriez-vous me dire ce qu'il se passe ?

Je ne comprends pas non plus pourquoi on ne met pas de END IF à la fin de cette ligne de code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
  If (IndiceMiseAJour = -1) Or (IndiceMiseAJour = ChampRecette) Then textChamp(ChampRecette).Text = ""
Un tout grand merci d'avance.

beegees