database will not remain open



I have a main database which I use like a switchboard to
open objects in other databases. I can open all but one
database using this switchboard. In database1
(switchboard) there is a button (cmd1) that when clicked
should open database2 (created by another user). The
database opens I log in, after logging in the database
closes. The code behind it is as follow

private sub cmd1_click()
Dim objACC As New Access.Application
Set objACC = GetObject
("C:\databases\database2.mdb") 'database to be opened
objACC.DoCmd.RunMacro ("mcrOpenEntryForm") 'marco to
End Sub

This is the same code I use to open other databases except
the path and the macro name is different in each case.

I've checked everything I can think of including the
macro, to make sure I am not quitting the database; I've
put a breakpoint in the code and stepped through it as it
ran and I've checked the database properties.

Any suggestions?




'69 Camaro

Any suggestions?
1.) Don't use macros. Use VBA procedures instead. There's no error
handling capabilities with macros so when something goes wrong while running
a macro, you will be clueless about what when wrong, what caused it, and how
to fix it. (Sound familiar?)

2.) Use error handling in your VBA procedures so that your application can
capture errors and handle them gracefully.

3.) When your procedures are finished using an object created in VBA code,
make sure that you release the memory for the object before the variable
goes out of scope. Otherwise, you'll have to wait for Visual Basic to do
the garbage collection for you, and that could easily mean that it never
gets done. This was particularly true with Access 97, where record sets
that weren't closed and set to nothing before procedures finished would
leave the Access 97 process running in the computer's memory, even after the
user closed the application.

4.) Use meaningful names for your objects so that a maintenance programmer
can quickly and easily make changes when necessary. For example, a button
named Command47 conveys no meaning for the programmer, while a button named
cmdOpenMonthlyReport will help the programmer quickly find the right code
segment to troubleshoot why the monthly report is being sent directly to the
printer, instead of displaying the monthly report for the user as expected.

5.) Check the code in the login form in database2.mdb for what happens
after you log in. If database2.mdb contains macros and VBA procedures
without error handling, then give the user who created that database the
advice listed above, also.



See for all your database needs.
See for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

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