Bonjour,

Nouvelle sur ce forum, cela fait plus d'1 jour que je cherche une réponse à ma problématique, en vain.
Je dois modifier une ancienne application développée sous Excel 2003 (par un collaborateur parti), qui pose problème aujourd'hui (je suis en Excel 2010) ; je précise que VBA n'est pas mon domaine de prédilection.

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
Private Sub dtgListUser_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
 
    Dim reponse As VbMsgBoxResult
    Static intRealLastRow   As Integer
 
    If UCase(mstrEtat) = "MODIF" Or UCase(mstrEtat) = "NEW" Then
        reponse = MsgBox("Vos modifications vont être perdues. Voulez vous continuer?", vbExclamation + vbYesNo)
    Else
        reponse = vbYes
    End If
 
    If reponse = vbYes Then        
        mblnNoChange = True
        txtNom.Text = Rst.getRecordSet.Fields("Nom").Value
        If Not IsNull(Rst.getRecordSet.Fields("Prenom").Value) Then
            txtPrenom.Text = CStr(Rst.getRecordSet.Fields("Prenom").Value)
        Else
            txtPrenom.Text = ""
        End If
        Select Case Rst.getRecordSet.Fields("Profil").Value
        Case "Administrateur"
            optProfilAdmin.Value = True
        Case "Consultant"
            optProfilConsultant.Value = True
        Case "Commercial"
            optProfilCommercial.Value = True
        End Select
        If Not IsNull(Rst.getRecordSet.Fields("Email").Value) Then
            txtEMail.Text = Rst.getRecordSet.Fields("Email").Value
        Else
            txtEMail.Text = ""
        End If
        chkActif.Value = Rst.getRecordSet.Fields("Actif").Value
        txtNomPC.Text = Rst.getRecordSet.Fields("NomPC").Value
 
        If IsNull(Rst.getRecordSet("colConsultant").Value) Then
            chkConsultant.Value = False
        Else
            chkConsultant.Value = True
        End If        
        mblnNoChange = False
        mstrEtat = "CONSULT"
        Call GestionEtat
    Else
        If LastCol = -1 Then LastCol = 0
        dtgListUser.Col = LastCol
        dtgListUser.Row = intRealLastRow        
    End If    
    intRealLastRow = dtgListUser.Row
 
End Sub
Private Sub MajTab()
 
    Set Rst = New CRequete
    MousePointer = fmMousePointerHourGlass
    Sleep (500)
    Rst.setConnectString (Connexion)
    Rst.setRequete "SELECT Nom, Prenom, Profil, Email, Actif, NomPC, Num, colConsultant " _
                   & "FROM Utilisateurs"
 
    Rst.Executer
 
    Set dtgListUser.DataSource = Rst.getRecordSet
    dtgListUser.Refresh
 
    MousePointer = fmMousePointerArrow
End Sub
Plusieurs Macro sont faites de cette manière dans l'application, et toutes posent le même problème. A l'exécution, j'obtiens le message suivant
"Erreur de compilation : Variable non définie" portant sur "dtgListUser".
Y a-t-il une déclaration particulière à faire concernant la Datagrid, ou une référence mal activée sous Excel ?

Si quelqu'un comprend pourquoi cette erreur pointe le bout de son nez, je suis preneuse !!

Meri d'avance