On timer close form o cualquier cosa....

Un lugar dónde compartir funciones, procedimientos y aplicaciones
AngelMiguel
Nivel 2
Mensajes: 26
Registrado: Mar Nov 21, 2017 4:34 pm

On timer close form o cualquier cosa....

Mensajepor AngelMiguel » Mar Ene 15, 2019 4:03 pm

En tu form

Private Sub Form_Timer()
On Error GoTo Form_Timer_Error

Call FormTimer(Me)

On Error GoTo 0
Exit Sub
Form_Timer_Error:
MsgBox "Error " & err.Number & " (" & err.Description & ") in procedure Form_Timer, line " & Erl & "."
End Sub

en un modulo

Public Sub FormTimer(ByRef frm As Access.Form)
Const IDLEMINUTES = 1

Static PrevControlName As String
Static PrevFormName As String
Static ExpiredTime

Dim ActiveFormName As String
Dim ActiveControlName As String
Dim ExpiredMinutes

On Error Resume Next

frm.TimerInterval = 1000
ActiveFormName = Screen.ActiveForm.Name
If err Then
ActiveFormName = "No Active Form"
err = 0
End If

ActiveControlName = Screen.ActiveControl.Name
If err Then
ActiveControlName = "No Active Control"
err = 0
End If

If (PrevControlName = "") Or (PrevFormName = "") _
Or (ActiveFormName <> PrevFormName) _
Or (ActiveControlName <> PrevControlName) Then
PrevControlName = ActiveControlName
PrevFormName = ActiveFormName
ExpiredTime = 0
Else
ExpiredTime = ExpiredTime + frm.TimerInterval
End If

ExpiredMinutes = (ExpiredTime / 1000) / 60
If ExpiredMinutes >= IDLEMINUTES Then
ExpiredTime = 0
frm.Undo
Msg = "No hemos detectado actividad por el usuario cerramos"
Msg = Msg & ExpiredMinutes & " minute(s)!"
MsgBoxEx frm.hwnd, Msg, 3, vbCritical, "Balances"
frm.cmdSalir_Click
End If
End Sub

Volver a “Almacén Accesiano”

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado