Bonsoir,
J’utilise VB2005 express et access.
Je souhaiterai mettre à jour de façons automatique la valeur de champs du type "modifier le".
Actuellement les fiches contenues dans mon formulaire sont mises en mouvement par une classe BindingNavigator.
Voici mon code:
Lorsque j'exécute ce code le champ est changé sur toutes les fiches.
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 Public Class f_tache Private Sub EnregistrerToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrerToolStripButton.Click Me.Validate() Me.lieuBindingSource.EndEdit() Me.LieuTableAdapter.Update(Me.Bd_eieDataSet.lieu) End Sub Dim modif As Single Private Sub f_tache_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed 'bloque le controle de mise a jour de modifier par modif = 0 Me.tacheBindingSource.EndEdit() Me.TacheTableAdapter.Update(Me.Bd_eieDataSet.tache) Me.lieuBindingSource.EndEdit() Me.LieuTableAdapter.Update(Me.Bd_eieDataSet.lieu) f_anim.charge_tache() End Sub Private Sub f_tache_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO*: cette ligne de code charge les données dans la table 'Bd_eieDataSet.anim'. Vous pouvez la déplacer ou la supprimer selon vos besoins. Me.AnimTableAdapter.Fill(Me.Bd_eieDataSet.anim) Me.SalarieTableAdapter.Fill(Me.Bd_eieDataSet.salarie) Me.TacheTableAdapter.Fill(Me.Bd_eieDataSet.tache) Me.AdresseTableAdapter.Fill(Me.Bd_eieDataSet.adresse) Me.LieuTableAdapter.Fill(Me.Bd_eieDataSet.lieu) If position.Text <> 0 Then tacheBindingSource.Position = position.Text - 1 If nouveau.Text = 1 Then tacheBindingSource.AddNew() 'active le controle de mise a jour de modifier par modif = 1 End Sub Private Sub EnregistrerToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrerToolStripButton1.Click Me.Validate() Me.tacheBindingSource.EndEdit() Me.TacheTableAdapter.Update(Me.Bd_eieDataSet.tache) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click f_carnet.Close() f_carnet.position.Text = Pers_refComboBox.SelectedValue f_carnet.MdiParent = f_contact_eie f_carnet.Show() End Sub Private Sub modif_par(ByVal sender As System.Object, ByVal e As System.Windows.Forms.BindingCompleteEventArgs) Handles tacheBindingSource.BindingComplete If modif = 1 Then Me.tacheBindingSource.Current.Row.Modif_le = DateString Me.tacheBindingSource.EndEdit() End If End Sub End Class
Quelqu’un aurai une idée?
Merci
Partager