Bonjour a tous !
J'essaye d'update une valeur dans une autre table que celle liee au formulaire mais je n'arrive pas acceder au bon ID, ca modifie toujours la premiere valeur de la table.
J'ai isole les lignes qui copient ma valeur: 21 a 24.
Il manque donc une instruction qui me premettrait d'acceder a la bonne valeur, du genre WHERE Me.Id = rsGiftStock!ID
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 Private Sub Form_BeforeUpdate(Cancel As Integer) Dim ctr As Control Dim rsGiftStock As Recordset Set rsGiftStock = CurrentDb.OpenRecordset("Gift Stock") 'for each field in the form For Each ctr In Me.Controls 'field filter Select Case ctr.ControlType Case acCheckBox, acTextBox, acComboBox, acListBox 'if current value is different from the old value If Nz(ctr.Value) <> Nz(ctr.OldValue) _ And ctr.Name <> "G2" And ctr.Name <> "GID2" And ctr.Name <> "CS2" _ And ctr.Name <> "R2" And ctr.Name <> "RD2" And ctr.Name <> "V2" _ And ctr.Name <> "UID2" And ctr.Name <> "MD2" Then Me.Modification_date = Date Me.User_ID = Environ("UserName") With rsGiftStock .Edit !Stock = Me.Current_stock .Update End With End If End Select Next rsGiftStock.Close End Sub
Si vous avez une idee ou des questions, n'hesitez pas !
Merci d'avance,
Poh
P.S.: Claviers chinois sans accent![]()
Partager