Hello,
I am using the below code to close the database after 10 minutes of idle time.
The issue I am having is that once the database closes after 10 minutes, I see a few pop up messages for my un-filled required fields and then I see an error message stating "Run-time error '-2147352567 (800200009)': You can't assign a value to this object." When I click on debug, I see the vba editor for a split second before it goes away so I can't tell where in the code it's giving me the error message.
FYI - I commented out the message box because I just want the program to close completely.
When I test for the idle time shutdown, I am in the Data Entry form on a new record because that's where it's designed to be at all times. In the new record, there are various fields that are required.
I added an acCmdUndo to my idle time code hoping that it will clear the form completely and allow the program to close without any pop up messages, but that is not working.
How can I get the program to close if it's left idle in a new record with un-filled (blank) required fields? FYI - the form is a bound form if that is of any use to my issue.
I am using the below code to close the database after 10 minutes of idle time.
The issue I am having is that once the database closes after 10 minutes, I see a few pop up messages for my un-filled required fields and then I see an error message stating "Run-time error '-2147352567 (800200009)': You can't assign a value to this object." When I click on debug, I see the vba editor for a split second before it goes away so I can't tell where in the code it's giving me the error message.
Code:
Option Compare Database
Private Sub Form_Timer()
Static OldcontrolName As String
Static OldFormName As String
Static ExpiredTime
Dim ActiveControlName As String
Dim ActiveFormName As String
Dim ExpiredMinutes
Dim msg As String
On Error Resume Next
ActiveControlName = Screen.ActiveControl.Name
ActiveFormName = Screen.ActiveForm.Name
Me.txtActiveForm = ActiveFormName
If (OldcontrolName = "") Or (OldFormName = "") _
Or (ActiveFormName <> OldFormName) _
Or (ActiveControlName <> OldcontrolName) Then
OldcontrolName = ActiveControlName
OldFormName = ActiveFormName
ExpiredTime = 0
Else
ExpiredTime = ExpiredTime + Me.TimerInterval
End If
ExpiredMinutes = (ExpiredTime / 1000 / 60)
Me.txtIdleTime = ExpiredMinutes
If ExpiredMinutes >= 10 Then
ExpiredTime = 0
'msg = "There has been no activity in the last "
'msg = msg & ExpiredMinutes & " minute(s)! Program will close."
'MsgBox msg, 48
'DoCmd.RunCommand acCmdUndo
If Me.Dirty = True Then
DoCmd.RunCommand acCmdUndo
DoCmd.Close
End If
Access.Quit
End If
End Sub
When I test for the idle time shutdown, I am in the Data Entry form on a new record because that's where it's designed to be at all times. In the new record, there are various fields that are required.
I added an acCmdUndo to my idle time code hoping that it will clear the form completely and allow the program to close without any pop up messages, but that is not working.
How can I get the program to close if it's left idle in a new record with un-filled (blank) required fields? FYI - the form is a bound form if that is of any use to my issue.