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
| Private Sub CmdFindInter_Click()
Dim i As Integer, Ctrl As Control, Trouve As Boolean
'#### Une DM existante a-t-elle été sélectionnée
Trouve = False
If pilot.ListIndex <> -1 Then
'#### Recherche de la ligne de la DM existante
For i = LigneInseree To DerniereLigne
If Trim(Sheets("BDD").Range("A" & i)) = Trim(pilot.Value) Then
Trouve = True
Exit For
End If
Next i
If Not Trouve Then
'#### Recablage des contrôles vers la bonne ligne si elle existe ou LigneInseree par défaut
For Each Ctrl In Me.Controls
Select Case TypeName(Ctrl)
Case "ComboBox", "TextBox"
If UCase(Ctrl.ControlSource) Like "BDD!*" Then
Ctrl.Enabled = True
Ctrl.ControlSource = Left(Ctrl.ControlSource, 5) & i
End If
Case Else
'Debug.Print TypeName(Ctrl)
End Select
Next
End If
End If
End Sub |
Partager