New Instance of Access

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I have come across a a situation where a form will not close when the form
close button is clicked or on clicking a command button with DoCmd.close
when I get a message that I cannot close the form as there is code running.

All I can do is close Access down, and then when checking the Task Manager I
still find an instance of Access running as a process but not as an
application. If I close thise instance of Access everything returns to
normal. I have not started this instance and I am not sure why it has
started.

The only difference to this form to any others I have created is that I am
now using a function to populate listboxes as the RowSourceType. Could this
be the problem?

Any help would be appreciated.

Steve
 
You probably have an open recordset that has failed to go out of scope when
the function ends. Explicitly close it in your code like this:

Exit_Here:
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub ' or function
Error_Handler:
MsgBox "Blah blah"
Resume Exit_Here

The other situation that causes this problem is failure to explicitly state
a boolean control. Instead of:

If Me.chkBox Then

use:

If Me.chkBox = True Then

or:

If Me.chkBox.Value Then
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
I am not sure if that is the cause as all my recordsets and connections are
declared in the function that requires them, and are all closed and
destroyed within the function either when I do not need them any more or
when the function ends.

I do use a recordset to populate list boxes via a RowSourceType function.
Even though I close the recordset and connection, could this cause a problem
when the list box is selected or refreshed?
 
1) This is not a new instance. This is what you see when
your existing instance fails to close cleanly.

2) No one has ever had problems with using a function
to populate a listbox. What kind of function are you
using (a call back function?). What version of Access
are you using? (At this time not many people would
have used callback functions in A2003, so maybe it is
a new problem)

3) Probably the most common cause of this kind of problem
was the use of constructs like:
if me.chkbox then
rather than
if me.chkbox.value then
or
if (false <> me.chkbox) then

Can you identify a bit of code that refers to an object
when you could be using a property of the object instead?

(david)
 
Back
Top