
Acc97: Application.Quit hangs task
Known bug, caused by an object reference that was not
correctly released. It takes some time to track this
one down, but there are 2 things to look for:
1. Boolean Controls:
===================
You referenced a check box, option button, or toggle button
like this:
If Me.chk Then
intending Access to understand interpret this as meaning the
default property (.Value). However, Access passed down an
object reference that is never relesed. Change your code to
explicitly reference the property, i.e.:
If Me.chk.Value Then
2. Objects not set to Nothing:
=============================
Access does a pretty good job of closing what you open and
dereferencing what you assign, but you cannot rely on it to
do so. Especially recordsets must be explicitly closed and
set to nothing. You need to make sure this happens regardless
of how the proc is terminated. Example:
---------------------------------
Function MyFunc
On Error GoTo Err_MyFunc
Dim db as Database
Dim rst as Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset(...
'Explictly close what you opened.
rst.Close
Exit_MyFunc
'Explicitly set all objects to Nothing here. Generally use
' reverse order, so as to handle dependencies.
Set rst = Nothing
Set db = Nothing
Exit Function
Err_MyFunc:
'error handler
Resume Exit_MyFunc
End Function
---------------------------------
Quote:
> In Access97 I have a command button with the simple code of:
> Application.Quit
> on the OnClick event.
> When I run the program in a runtime environment on an NT4.0 desktop,
> the task won't shutdown completely. The window closes, but the task
> tab stays active. I have to use Task Manager to manually end the task.
--
Perth, Western Australia
Tips for MS Access users at:
http://odyssey.apana.org.au/~abrowne