How to check if ODBC connection available?

bulrush

Registered User.
Local time
Today, 15:29
Joined
Sep 1, 2009
Messages
209
I'm using ACC2000. (Don't ask me to upgrade to ACC2007, it's awful!!)

I have an app that links some tables in from an ODBC source which uses a login name and password. When the user clicks a button I want to first check that the ODBC connection is available before I try to get data from the linked tables.

How do I do that? I basically want to trap the error of trying to read a linked table that isn't there anymore, before the error happens.
 
Have you tried opening a connection in the VBA code? You should be able to trap error in the code and handle it accordingly.
 
I think my problem is, when I open the MDB file, Access will try to look at the linked tables, and I will get an error at that point, which I will not be able to trap, since I haven't opened any Access objects, like a form. Hmm.
 
If you create an AutoExec macro, it can use

RunCode

and then run any public function. The autoexec macro will fire before ANYTHING else, including trying to link to the tables. So, you can check there.
 
That doesn't sound right to me.

Normally, if you merely open .mdb files, there should be no error until you open any specific object (e.g. a table or query or form).

Did you try holding the shift bypass down? If this worked, then it indicates you have code maybe in the AutoExec macro or the startup form that is forcing loading of the table too prematurely and needs to be revised so that you can trap for errors there.

I just created a linked table, and changed its connection string to an invalid string, saved it then closed Access. Opening it didn't cause any errors; only when I attempt to open the linked table.
 

Users who are viewing this thread

Back
Top Bottom