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
| Option Compare Database
Option Explicit
Private Function ExaminerValeurCdes() As Boolean
Const CLOTURE As String = "en cours clôture"
Const ATTENTE As String = "en attente"
Dim oRS As DAO.Recordset
Dim strSQLExamenCdes As String
Dim dtmDateForclusion As Date
strSQLExamenCdes = "SELECT Date_forclusion, Travaux_cloturé FROM TaTable"
Set oRS = CurrentDb.OpenRecordset(strSQLExamenCdes, dbOpenDynaset)
With oRS
Do While Not .EOF
Select Case .Fields("Travaux_cloturé")
Case CLOTURE, ATTENTE
AfficherAlerte = True
Exit Do
End Select
If .Fields("Date_forclusion") + 6 >= Now Then
AfficherAlerte = True
Exit Do
End If
.MoveNext
Loop
End With
Set oRS = Nothing
End Function
Public Function AfficherAlerte()
If ExaminerValeurCdes = True Then
MsgBox "Il y a au moins une commande concernée par le truc _
que je veux vérifier !", vbExclamation
DoCmd.OpenForm "frmListeDesCommandesConcernees", _
acNormal, , , , acDialog
End If
End Function |
Partager