How can i trap the closing time of an application.
Printable View
How can i trap the closing time of an application.
If you know which form will close last, use the Now() function to return the current date and time.
The Now function is good to capture both the date and time, or you can use the Time function to just capture when the app is unloaded.
Code:'When X Button is clicked
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Open App.Path & "\unloaded.txt" For Append As #1
'Append is used if you want to add to the file
'Output is used to overwrite the file
Print #1, Now() 'or Time()
Close #1
End Sub
'Or:
Private Sub Form_Unload(Cancel As Integer)
Open App.Path & "\unloaded.txt" For Append As #1
Print #1, Now() 'or Time()
Close #1
End Sub