Je veux faire une mise à jour d'un enregistrement à partir d'une fiche de modification. Pour celà j'affiche les 2 formulaires correspondants les champs en rouge à gauche vont mettre à jour les champs en rouge à droite, voir PJ.
J'examine un à un les champs (indexés) et j'ai toujours l'erreur 2465 sur la ligne Form1!Champ(i) = Form2!Champ(i)
j'ai la même erreur si j'écris
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 Private Sub Bt_modif1_Click() Dim champ_tabexcel, champ_inv0 As Variant ' traitement modification Set bdd = CurrentDb 'initialisation de l'index de lecture des champs ind = 0 lecture: 'examen imp_tabexcel If Forms!imp_tabexcel.Controls(ind).ControlType = acTextBox Or Forms!imp_tabexcel.Controls(ind).ControlType = acComboBox Or Forms!imp_tabexcel.Controls(ind).ControlType = acListBox Then 'mémorisation de la valeur du champ tabexcel champ_tabexcel = Forms!imp_tabexcel.Controls(ind) 'mémorisation de la valeur du champ de l'enreg. inv0 champ_inv0 = Forms!imp_inv0.Controls(ind) Else: GoTo incr End If If Not IsNull(champ_tabexcel) And IsNull(champ_inv0) Then ' j'obtiens l'erreur sur 2465 sur la ligne suivante Forms!imp_inv0.Control(ind) = Forms!imp_tabexcel.Controls(ind) GoTo incr End If If champ_tabexcel <> champ_inv0 Then et bien sûr sur celle ci Forms!imp_inv0.Control(ind) = Forms!imp_tabexcel.Controls(ind) GoTo incr End If incr: ind = ind + 1 If ind > 50 Then Exit Sub Else GoTo lecture End If End Sub
ou
Code : Sélectionner tout - Visualiser dans une fenêtre à part Forms!imp_inv0.Control(ind).controlsource = Forms!imp_tabexcel.Controls(ind).controlsource
Un grand merci si vous pouvez m'aider
Code : Sélectionner tout - Visualiser dans une fenêtre à part Forms!imp_inv0.Control(ind).value = Forms!imp_tabexcel.Controls(ind).value
Partager