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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| Dim db As DAO.Database: Set db = CurrentDb
Dim MSG As String
Dim R2 As DAO.Recordset: Set R2 = db.OpenRecordset("Stage", dbOpenDynaset)
Dim R As DAO.Recordset: Set R = db.OpenRecordset("Intervention", dbOpenDynaset)
Dim dateFI As Variant: dateFI = Me.DateInterventionFiche
Dim DateSortie As Variant
Dim IDActionFI As Variant: IDActionFI = Me.IDAction
Dim Present As Boolean
Dim MsgEffacer As Boolean: MsgEffacer = False
'---------Demarge de la boucle -----------------
MSG = MsgBox("Lancement de lintégration des stagiaires..." & vbCrLf & "Cela peut prendre quelques temps", , "Info")
MsgEffacer = False
With R2 'With 1 Debut ---------
If .RecordCount <> 0 Then 'If 2 Debut ----------
.MoveFirst
Do While Not .EOF 'Debut do While ---------------------
If IsNull(R2![Date_Sortie_reel]) Then DateSortie = R2![Date_Sortie]
If Not IsNull(R2![Date_Sortie_reel]) Then DateSortie = R2![Date_Sortie_reel]
If R2![Date_Sortie] >= dateFI And R2![Date_Entrée] <= dateFI And R2![IDAction] = IDActionFI Then 'If 3 Debut --------------
'--------------------------------------------------------------------
'--------------------------------------------------------------------
'---------Démarrage de la boucle R -----------------------------------
Present = False
With R 'With R Debut ---------
If .RecordCount <> 0 Then 'If 2 Debut ----------
.MoveFirst
Do While Not .EOF 'Debut do While ---------------------
If R![Stagiaire] = R2![ID_Stagiaire] And R![HeureMatin] = "07:00:00" And R![DateInterventionIndi] = dateFI Then 'If 3 Debut --------------
Present = True
.MoveNext
Else 'If 3 si fausse ----------------------------------------------------
'-----
If R![Date_Sortie_reel] < R![DateInterventionIndi] Then
R.Edit
R![Effacer] = -1
R.Update
MsgEffacer = True
Else
R.Edit
R![Effacer] = 0
R.Update
End If
'-----
.MoveNext
End If 'If 3 si fausse ----------------------------------------------------
Loop 'Fin do While ---------------------
End If 'If 2 Fin ----------
End With 'With 1 Fin ---------
If Present = False Then
'Addition de champ-------------------------
'MSG = MsgBox("Creation de ligne", , "Info")
R.AddNew
R![Stagiaire] = R2![ID_Stagiaire]
R![ContenuIndividualise] = "nouveau"
R![DateInterventionIndi] = dateFI
R![IDAction_Int] = R2![IDAction]
R![HeureMatin] = "7:00"
R.Update
'Fin addtion----------------------------------
End If
.MoveNext
Else 'If 3 si fausse ----------------------------------------------------
.MoveNext
End If 'If 3 si fausse ----------------------------------------------------
Loop 'Fin do While ---------------------
End If 'If 2 Fin ----------
End With 'With 1 Fin ---------
MSG = MsgBox("Fin de lintégration des stagiaires..." & vbCrLf & "Merci de votre patience", , "Info")
If MsgEffacer = True Then MSG = MsgBox("Un ou plusieurs stagiaires ne devant pas être présent le " & dateFI & " a été trouver" & vbCrLf & "Merci de vérifier" & vbCrLf & " les dates d'entrées" & vbCrLf & " les dates de sorties" & vbCrLf & " et les dates de sorties réelles" & vbCrLf & "des stagiaires marquer en rouge", , "ATTENTION")
If Present = True Then MSG = MsgBox("Un ou plusieurs stagiaires est présent Plusieurs fois le " & dateFI & vbCrLf & "Merci de vérifier", , "ATTENTION")
DoCmd.RunCommand acCmdRefresh
R.Close: Set R = Nothing
R2.Close: Set R2 = Nothing
End Sub |
Partager