Controlled Exit when Access database opens with broken vba references

BiigJiim

Registered User.
Local time
Today, 18:02
Joined
Jun 7, 2012
Messages
114
Hi,

I have a number of different mdb databases which all use a couple of common functions. Instead of inserting the function into each database, I have each one referencing an mde file containing the functions in the same directory.

My problem is that if an mdb opens and the mde does not exist (e.g. was deleted) I immediately get a "compile error: can't find project or library" message. I have tried inserting code to check for broken references on startup, but this has no effect.

All I would like to do is for the mdb application to detect that the reference is missing and to close in a controlled manner. Is this possible?

Thanks for reading and for any assistance you can provide.
Jim
 
A work around. Use another mdb to open the target mdb. This new mdb would first check for the existence of the mde and could even copy/paste it from a backup folder if missing.
 
Thanks for the suggestions guys. I am not sure either of these will help me though.

A work around. Use another mdb to open the target mdb. This new mdb would first check for the existence of the mde and could even copy/paste it from a backup folder if missing.

How would this work? Would this not be just transferring the problem? (i.e. if the launcher file was deleted, how could I stop users opening the main mdb.)


Thanks CJ. A lot of useful information here, it also led me to

http://www.trigeminal.com/usenet/usenet026.asp

but I am not sure what Michael Kaplan is proposing is feasible (re-write every single function call?) I have also found all the code to check broken references, remove them and re-add them. The problem is the code won't compile in the 1st place if the broken reference exists.

Surely there must be an easier way of doing this?
 
Think I might have fixed it, for anyone else with the same issue. Have a look at the Michael Kaplan link I posted above for more info.

Basically, your startup code should contain a simple procedure to check if the file exists and if so, calls whatever other code you want to run, stored in another module. If not, quits the application. THERE SHOULD BE NOTHING ELSE IN THIS MODULE.

Hope this helps! Thanks for all your help guys!
 
Think I might have fixed it, for anyone else with the same issue. Have a look at the Michael Kaplan link I posted above for more info.

Basically, your startup code should contain a simple procedure to check if the file exists and if so, calls whatever other code you want to run, stored in another module. If not, quits the application. THERE SHOULD BE NOTHING ELSE IN THIS MODULE.

Hope this helps! Thanks for all your help guys!

BiigJiim, Thanks for your post.
It seems that the great trigeminal.com posts does not more exist.
do you have an off-line copy of this document? ( http://www.trigeminal.com/usenet/usenet026.asp )
anyway, thanks.

Guillem
 
calling user-defined function IsMissingRef() from Autoexec macro to check for missing reference (sample).
to be able to see the code, hold down the Shift key while clicking (opening) the db.
 

Attachments

Hi Guillem
The thread is about 4 years old but its only recently that the Trigeminal site went down - its listed on my Useful Links webpage. As its now redirecting to the FMS site, I would contact them as they may now be hosting the content.

In the meantime, in case its any use, see my code sample for checking the list of VBA References & Locations
 
Last edited:
many thanks to Arnelgp and Isladogs for the help

guillem
 
many thanks to Arnelgp and Isladogs for the help

guillem
Hi Guillem,

Unfortunately I don't have an offline copy. What is it you are trying to do? Basically I got it to work by running a procedure on startup which checked for the existence of the reference dB and quit the application if it wasnt found, or loaded a 2nd startup routine if it did, to do all your normal database startup stuff. You have to have this 1st startup routine in a separate module, on its own, and not using any references to the reference database. Hope that makes sense!
 
Hi Guillem,

Unfortunately I don't have an offline copy. What is it you are trying to do? Basically I got it to work by running a procedure on startup which checked for the existence of the reference dB and quit the application if it wasnt found, or loaded a 2nd startup routine if it did, to do all your normal database startup stuff. You have to have this 1st startup routine in a separate module, on its own, and not using any references to the reference database. Hope that makes sense!
Thanks Biig Jiim,
 
This could be useful for many things. In addition to broken references, to check if the back-end server is available, to check if an admin has locked it for maintenance, etc.
 

Users who are viewing this thread

Back
Top Bottom