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
| Dim db As DAO.Database
Dim rstT_Demandeur, rstT_EBC1 As DAO.Recordset
Dim a As Boolean
Set db = CurrentDb
a = False
'On attache les tables à la variable table
Set rstT_EBC1 = CurrentDb.OpenRecordset("T_EBC1", dbOpenDynaset)
Set rstT_Programme = CurrentDb.OpenRecordset("T_Programme", dbOpenDynaset)
'Mise à jour des champs de nom
Do While Not rstT_EBC1.EOF
' Si le champ Nom de l'EBC est nul on passe à la case suivante, sinon
'on parcourt la table demandeur pour voir si le nom existe déja.
' A noter que les colonnes de programme sont programme, origine, pays, demandeur, budget, budget oui/non,
'les colonnes numéro 5, 3, 4, 13,
If IsNull(rstT_EBC1.Fields(5)) = False Then
If rstT_Programme.RecordCount > 0 Then
rstT_Programme.MoveFirst
Do While (Not rstT_Programme.EOF) And a = False
If rstT_Programme.Fields(0).Value = rstT_EBC1.Fields(5).Value Then a = True Else rstT_Programme.MoveNext
Loop
End If
'Si le nom n'existe pas, autrement dit a = False, on l'insère
If a = False Then
rstT_Programme.AddNew
rstT_Programme.Fields(0).Value = rstT_EBC1.Fields(5).Value
rstT_Programme.Fields(1).Value = rstT_EBC1.Fields(3).Value
rstT_Programme.Fields(2).Value = rstT_EBC1.Fields(4).Value
rstT_Programme.Fields(3).Value = rstT_EBC1.Fields(13).Value
rstT_Programme.Update
End If
End If
a = False
rstT_EBC1.MoveNext
Loop
'Fermeture des objets
rstT_EBC1.Close
rstT_Programme.Close
Set rstT_EBC1 = Nothing
Set rstT_Programme = Nothing |
Partager