Bonjour à tous
Je viens vers vous car j'ai un soucis avec mon code ci-dessous :
Lorsque j'ai plusieurs enregistrements dans ma table T_import : tout marche bien.
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 'insertion dans 2 tables séparées Dim nb As Integer Dim NUM As Variant Dim dbs As DAO.database Dim rst, rst1, rst2, rst3 As DAO.Recordset DoCmd.SetWarnings False Set dbs = CurrentDb Set rst = dbs.OpenRecordset("T_import") Set rst1 = dbs.OpenRecordset("T_contact") Set rst2 = dbs.OpenRecordset("T_Entreprise") Call ImportAccountingDataWeb 'importation dans la T_import ça marche bien Do Until rst.EOF With rst1 .AddNew .Fields("CIVILITE").Value = rst.Fields("CIVILITE") .Fields("DIR_NOM").Value = rst.Fields("DIR_NOM") .Fields("FONCTION").Value = rst.Fields("FONCTION") .Update End With Set rst3 = dbs.OpenRecordset("select * from t_contact order by t_contact![N°] desc") NUM = rst3.Fields("N°").Value With rst2 .AddNew .Fields("CA").Value = rst.Fields("CA") .Fields("RESULTATNET").Value = rst.Fields("RESULTATNET") .Fields("auto").Value = NUM .Update end With rst.MoveNext Loop DoCmd.SetWarnings True End Sub
Mon problème arrive lorsque je n'ai qu'un enregistrement dans ma table T_import ma 1ère boucle ne se fait pas.
Je dois oublier quelque chose, mais quoi ??
Merci d'avance
Mamanhou
Partager