Code to Check Backend Location

Tezcatlipoca

Registered User.
Local time
Today, 12:57
Joined
Mar 13, 2003
Messages
246
Ok, this is really just a general query more than anything, but I've been unable to find the answer either here on on the internet in general.

I have a secured database. BE is password protected and all objects are hidden. FE is MDE, all objects hidden, shift disabled, special keys disabled, and opens into a locked down user verification screen. Everything is modal and popup, so there's no access to Access behind.

One possible hole I've noticed, though, is if I take the BE away from the folder where the FE expects to find it, loading the FE gives me a warning, then crashes back into Access, even for the MDE. Obviously, being MDE, there are severe restrictions on what the user can do, but I don't like the fact it's gone back to Access at all.

I have a number of modules running in my database (disable shift key, disable mouse wheel, and so on), so would like to know if there's any code that scans for the BE before anything else takes place, then allows me to dictate behaviour if it is not found.

Anyone?
 
Last edited by a moderator:
an easy way is to take any linked table, and see if you can open it
if not the backend is missing

so just pick a small table and try

on error goto notables:
items = dcount("*","smalltable")

notables:
lavel for exceptions

then you need to decide how to deal with the problem, but this will stop access crashing
 
Last edited by a moderator:
an easy way is to take any linked table, and see if you can open it
if not the backend is missing

so just pick a small table and try

on error goto notables:
items = dcount("*","smalltable")

notables:
lavel for exceptions

then you need to decide how to deal with the problem, but this will stop access crashing

Sorry, I'm not too sure I get you. I know how I can easily test whether the tables are linked or not, but what I'm after is some kind of code or module that checks the BE is present before loading anything that would rely on said BE. If it finds it missing, I want to completely control what happens, rather than Access' default of opening itself up.

Surely if I introduce code that interacts with a table in the BE database (such as a DCount), I'm still going to run into Access complaining it can't find the table?
 
Last edited by a moderator:
yes, hence the extra code, highlighted in red

if the table does not exist, access throws an error- which is trapped, and which transfers control to the designated label, for you to decide how to deal with the problem

what i do now is open a form to "pick" an appropriate backend, and then reconnect the tables, and then restart.

however you have to do something
- you could go back to the database window - but you don't want to show users the dbs window
- you could just quit access, but then you might find yourself locked out of the app
- you could go back to the dbs window, but only if you are using a certain terminal, or for a certain user - but this depends how you log users in.

Code:
'set up the error handler
[COLOR="Red"]on error goto notables[/COLOR]
items = dcount("*","smalltable")

'continue normmlly
exit sub

notables:
msgbox("Back end not linked correctly")
[COLOR="red"]resume quitaccess[/COLOR]
'IMPORTANT if you dont quit access, you need a RESUME statement

quitaccess:
'command to quit access

end sub
 
yes, hence the extra code, highlighted in red

if the table does not exist, access throws an error- which is trapped, and which transfers control to the designated label, for you to decide how to deal with the problem

what i do now is open a form to "pick" an appropriate backend, and then reconnect the tables, and then restart.

however you have to do something
- you could go back to the database window - but you don't want to show users the dbs window
- you could just quit access, but then you might find yourself locked out of the app
- you could go back to the dbs window, but only if you are using a certain terminal, or for a certain user - but this depends how you log users in.

Code:
'set up the error handler
[COLOR="Red"]on error goto notables[/COLOR]
items = dcount("*","smalltable")

'continue normmlly
exit sub

notables:
msgbox("Back end not linked correctly")
[COLOR="red"]resume quitaccess[/COLOR]
'IMPORTANT if you dont quit access, you need a RESUME statement

quitaccess:
'command to quit access

end sub

Aah, gotcha! Thanks Gemma. As always, you are a huge benefit to these forums :)
 

Users who are viewing this thread

Back
Top Bottom