Idea: - When you leave the program running and do not move the mouse
After a certain period, let it be two minutes, the open form will be closed and it will return to the user interface (login).
Idea: - When you leave the program running and do not move the mouse
After a certain period, let it be two minutes, the open form will be closed and it will return to the user interface (login).
in the form set the ON TIMER INTERVAL property to 60000 (60 seconds,aka 1 min, aka 60000 millisecs)
then the mouse & keystrokes will reset the counter
in ON CLOSE event, it should just show the menu behind it, or you can call the f.LOGIN
Code:'form (module) level counter private mlMins as long Private Sub Form_Timer() mlMins = mlMins + 1 If mlMins = 2 Then DoCmd.Close End Sub Public Sub ResetTimer() Me.TimerInterval = 0 Me.TimerInterval = 60000 mlMins = 0 End Sub Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) ResetTimer End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) ResetTimer End Sub
I will try it and get back the results
My Test
I need when the "Form1" Closed "Form2" Open
in FORM_CLOSE event , open yr other form:
Code:Private Sub Form_Close() DoCmd.OpenForm "form2" End Sub
Or just don't close the form you want to return to in the first place. DoCmd.Close will close the active form and that changes as opened forms close. Best to refer to the object by name if you can. I'd do something like
EDIT - I gather that you don't use Option Explicit or Option Compare in any of your databases because neither is used in the one you posted.Code:Private Sub Form_Timer() Dim frm As Form mlMins = mlMins + 1 If mlMins = 2 Then For Each frm In Forms If CurrentProject.AllForms(frm.Name).IsLoaded And frm.Name <> "form1" Then DoCmd.Close acForm, frm.Name End If Next 'DoCmd.OpenForm "Form1", acNormal End If Change <> "form1" to the name of the form you'd want to leave open. If it happens that it's not open, it won't matter because it isn't loaded. End Sub
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.