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
| Private Sub Form_Timer()
' toutes les xx secondes, vérification du flag Logoff et des heures d'ouverture
On Error GoTo Err_LogOffChk
Dim Lancer As Boolean, t_max As Variant, t_min As Variant, t As Variant, user As String
Dim rcd As Recordset
Set rcd = CurrentDb.OpenRecordset("Admin", dbOpenSnapshot)
user = Environ("username")
rcd.MoveFirst
Lancer = rcd!logoff
t_max = rcd!time_max
t_min = rcd!time_min
rcd.Close
CurrentDb.Close
' --Si la case est cochée ou heure dépassée
If Lancer Or Time() > t_max Or Time() < t_min Then
Call flog("Fermeture", "Admin")
Application.Quit acQuitSaveAll
End If
' test si message
If DCount("dest", "mess_a_voir") > 0 Then
DoCmd.OpenForm "mess_a_voir"
Call Shell("wscript.exe t:\mess.vbs", 1)
End If
Exit_LogOff:
Exit Sub
Err_LogOffChk:
MsgBox Err.Number & vbCrLf & Err.Description, vbInformation, "Erreur"
Resume Exit_LogOff
End Sub
test à l'ouverture :
Private Sub Form_Open(Cancel As Integer)
' à l ouverture du formulaire (et donc de la base), on vérifie si on peut l'ouvrir via admin
Dim Lancer As Boolean, t_max As Variant, t_min As Variant, t As Variant
Dim rcd As Recordset
Set rcd = CurrentDb.OpenRecordset("Admin", dbOpenSnapshot)
rcd.MoveFirst
Lancer = rcd!logoff
t_max = rcd!time_max
t_min = rcd!time_min
rcd.Close
CurrentDb.Close
' --Si la case est cochée
If Lancer Or Time() > t_max Or Time() < t_min Then
Call flog("fermeture", "Pas autorisé")
DoCmd.OpenForm "bye", acNormal, , , acFormReadOnly, acDialog
End If
Call flog("Ouverture", "") |
Partager