By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,662 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,662 IT Pros & Developers. It's quick & easy.

Avoid message "Could not find file... database_path"

100+
P: 759
Hello !

"Could not find file... database_path"
This message appear if a front end database could not find the back end database.

I have a form set as StartUp form. I try to put code in associated events (On_Load and On_Open) to intercept the error but it seems that no code is running either before either after that message appear.

Is it possible to treat this error ? Simple I wish to show a message like "Reconnect your interface to the database, please" instead the default message.

Thank you !
Nov 28 '11 #1
Share this Question
Share on Google+
12 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
Its been a while since I've since this error.
Does it have a number?
Nov 28 '11 #2

100+
P: 759
No. It hasn't a number. It is only a message.

Change the name for a back end database (where you have tables) then try to open a front end based on this tables. You will see the message.

Of course, if you restore the old name all is Ok again.
As far as I can think, that is a message from the database engine (JET ???).
The question is: can be intercepted in order to run code to handle this error ?

Thank you for interest, Smiley !
Nov 28 '11 #3

NeoPa
Expert Mod 15k+
P: 31,271
In my tests this error message is only triggered when an access is attempted to one of the linked tables. I suspect you have something running automatically that includes such an access.

You should try checking this as a first step in your code. Relinking ODBC Tables using VBA should have all the information you need for this, but let us know if you need anything explained.
Nov 28 '11 #4

TheSmileyCoder
Expert Mod 100+
P: 2,321
Im unsure as to whether the exact error message can be trapped.

There are 2 situations here to consider, the one your describing where you rename the backend can be handled by this:
You need a startup form that does NOT bind to a recordset (because if it does, access will try to load it, causing said error) that runs the following code:
Expand|Select|Wrap|Line Numbers
  1. If Dir("G:\MyPath\MyDB.mdb") & ""="" Then
  2.   Msgbox "BackEnd not found"
  3.   Docmd.Quit 'Or whatever you want
  4. end If

I have a similar problem, which the above would not solve, namely that when users go to lunch their computers go in standby mode and apparntly so does their network adaptor (im guessing) and when they return they get said error message (or something similar) and have to restart the tool. Annoying.

So Im hoping your problem fits into the first category.
Nov 28 '11 #5

NeoPa
Expert Mod 15k+
P: 31,271
Smiley:
I have a similar problem, which the above would not solve, namely that when users go to lunch their computers go in standby mode and apparntly so does their network adaptor (im guessing) and when they return they get said error message (or something similar) and have to restart the tool. Annoying.
Why not post on that and we can look at possible ways of getting around it. I suffer from that too sometimes and it may be worth spending some time designing a professional way to handle it (Even if it's only to warn the user in a friendly way and ensure that the database is re-opened). Not in this thread though of course ;-)
Nov 28 '11 #6

100+
P: 759
Thank you, both, for answers.

Yes: the start up form is bind to a table.
I'll try Smiley code and I return here to inform you about results.

Thank you again !
Nov 28 '11 #7

NeoPa
Expert Mod 15k+
P: 31,271
In that case make your startup form a separate, unbound, form that does the checks and immediately opens the original form if, and only if, everything is ok. Otherwise it handles whatever you need at that point.
Nov 28 '11 #8

100+
P: 759
Hi, again.

Smiley !
Every time I receive code from you, I can use it with no modifications. So I am pretty sure that your code is correct and functional. But I don't try it because I understand that it is not what I am looking for.

It is not useful for me to check IF or IF NOT the back end part is stored in a certain folder under a certain name.

Let me explain why:
On my own computer the back end part is in a folder MyPath\BackEnd.mdb
I link the front end part to the BackEnd.mdb , so MY front end part look in MyPath to find BackEnd.mdb

First reason, but not the main reason:
I don't wish to force the user to use the same path structure as me and the same name for the BackEnd.mdb as me.
So, if the user use another path than me (or another name for the back end part, or both), your code will show the message "BackEnd not found" even if the front end is linked to the back end and all is ok.

The main reason:
The back end part is stored on a computer and the front end part run from different computers in the same network.
So it has no utility to check if the back end is in a certain location.

The main main :) reason:
I don't like to use TeamViewer to relink front end part to the back end part whenever I add a feature to one of the front end part (there are three)

So the first question remain:
How to intercept the error message in order to handle it.
Or, in a boolean logic, how to know if the front end is properly linked to the back end BEFORE the error raise ?

Ufff. I think that I use all the English words I know.
Thank you for the patience.
Nov 28 '11 #9

100+
P: 759
I remember some unused English words, NeoPa :)

I know how to relink a database from VBA. Starting with this code I wish to design a wizard.
But when I must run this wizard ?
Nov 28 '11 #10

NeoPa
Expert Mod 15k+
P: 31,271
Mihail,

Smiley's code just about does all that you ask. The only exception I can see is that it assumes you already know the location of the file that your tables are linking to. If you don't then (assuming you know at least one of your tables that links to the back-end file - and if you don't then you probably need to give up now :-D) you can get the value from :
Expand|Select|Wrap|Line Numbers
  1. Split(CurrentDb.TableDefs("XXX").Connect, "=")(1)
where [XXX] is the name of the linked table.

From there you have already been told how to arrange the forms such that this is tested before it falls over, and Smiley's code would be used (with the minor amendment here) in the Form_Open() event procedure of that form.
Nov 28 '11 #11

100+
P: 759
Only two line of code between me and happiness !!!

First half from you, NeoPa and the second from you, Smiley

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Dim ExpectedPath As String
  3.     ExpectedPath = Split(CurrentDb.TableDefs("Noduri").Connect, "=")(1)
  4.     If Dir(ExpectedPath) & "" = "" Then
  5.         MsgBox "BackEnd not found"
  6.     Else
  7.         DoCmd.Close acForm, Me.Name
  8.         DoCmd.OpenForm "StartingFormName"
  9.     End If
  10. End Sub
I'll put this code on the first form of the wizard.
If all is Ok the wizard will be close (line 7) and the first form of the front end part will be opened (line 8).
If not the wizard continue and show it's first form.

THANK YOU, both, VERY MUCH !
Nov 28 '11 #12

NeoPa
Expert Mod 15k+
P: 31,271
Great :-) All sorted now.
Nov 28 '11 #13

Post your reply

Sign in to post your reply or Sign up for a free account.