Access database is not opening a second time?

G

Guest

Hi, when I close down my Access database after entering new data, I am unable
to open it a second time. The LDP file appears, and access is running, but
the database itself is unable to open. This is only after I've performed some
tasks in the database, i can open and close it without changing anything and
there is no problem. Otherwise I have to open the task manager, end process
MSACCESS, then delete the LDP file before I can reopen the database. What's
happening and how can I fix it?
 
V

Van T. Dinh

The previous instance of MSAccess + database are still in the memory which
prevents you to open it the second time.

Make sure that in VBA code, you close all Database / Connection / Recordset
objects when you finish with them and set the Object Variables to Nothing.
Unclosed objects tends to prevent Access from exiting cleanly.
 
G

garret

Van said:
The previous instance of MSAccess + database are still in the memory which
prevents you to open it the second time.

Make sure that in VBA code, you close all Database / Connection / Recordset
objects when you finish with them and set the Object Variables to Nothing.
Unclosed objects tends to prevent Access from exiting cleanly.

Don't all variables and objects go out of focus after a code sequence
which uses them is over, therefore either destroying them or setting
them back to nothing? I've never had to set variables back to nothing
before exiting. What do you mean "close" Database / Connection /
Recordset objects?
If this need be the case, and I've just been fortunate, how would I go
about doing this?
 
V

Van T. Dinh

What you wrote is true in theory.

However, we occasionally find that Access / Access VBA leave objects behind
so it is always good practice that if you create an object, you close it and
set the Object Variable to Nothing.

See my other post in this thread also.
 
G

garret

Do you mean "close" it BY setting it back to nothing? I don't know
what the term close is. And to do this, is there a way in a kind of
Application_close event to set all variables to nothing, or do you mean
to just set them back to nothing at the end of a procedure...even so,
you might need that value later depending if it is a global variable or
not.
 
V

Van T. Dinh

For example, if you open / create a Recordset object rst, you close it with:

rst.Close
Set rst = Nothing

In practice, I find setting Object Variables to Nothing without closing also
closes the Objects but I prefer "defensive" coding.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top