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
|
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo captErreur
Dim InfosMaj As String
Dim LeCtrl As control
' Au cas où l'on veut savoir si un enregistrement a été ajouté
' If Me.NewRecord = True Then
' InfosMaj = InfosMaj + vbCrLf + "1 nouvel enregistrement a été ajouté"
' End If
' Passe en revue tous les champs pour connaitre les changements
For Each LeCtrl In Me.Controls
Select Case LeCtrl.ControlType
Case acTextBox, acComboBox
If IIf(IsNull(LeCtrl.Value), "", LeCtrl.Value) <> LeCtrl.OldValue Then
InfosMaj = InfosMaj + vbCrLf + "Valeur champ " + LeCtrl.Name + " : " + Format(LeCtrl.OldValue) + " - remplacée par : " & Format(LeCtrl.Value)
End If
End Select
Next LeCtrl
'Mise à jour du champs traceur de modifications
If InfosMaj <> "" And Not IsNull(InfosMaj) Then
Forms!Monformulaire!lechampMemo = InfosMaj
End If
degage:
Exit Function
captErreur:
If err.Number <> 64535 Then
MsgBox "Erreur N°: " & err.Number & vbCrLf & "Description: " & err.Description
End If
Resume degage
End Function |
Partager