Getting Path/Directory to Backend

D

dan

Hi;

This is my second attempt at this. I have a database
with a front-end and back-end. Checking to see if the
front-end is linked to the back-end table is NOT my
problem. I have code that does that and my tables are
linked properly.

What I want to do is just load a string variable with the
path/directory/filename of the back-end database. I can
do this for the front-end with this code:

Public glCurrentfe As String
Dim dbs As DAO.Database

Set dbs = CurrentDb
glCurrentfe = dbs.Name

The global variable glCurrentfe would now contain the
path/directory/filename of the front-end database. How
do I get a variable loaded with the back-end database?
I'm not interested in checking links or linking it
because it's already been linked. I just want to get the
path/directory/name of the back-end database into a
string variable.

Thanks,
Dan
 
A

Allen Browne

Parse it from the Connect property of the TableDef:
dbEngine(0)(0).TableDefs("MyTable").Connect
 
D

Dan

Sorry Allen, but I'm new to this.

If the string I wanted to populate is glCurrentbe and my
database front-end and back-end are named
Project_FrontEnd and Project_BackEnd; how would the code
look?
 
A

Allen Browne

Assuming that "SomeTable" is the name of an attached JET table:

glCurrentBe = Mid(dbEngine(0)(0).TableDefs("SomeTable").Connect, 11)
 
D

Dan

That's the problem Allen. At the time this code runs
(initiallization), I don't know the name of the back-end
database!
 
D

Dan

I can find the front-end in the Name property, but the
Connect property is "". The front-end and back-end have
been connected previously though because I can find the
back-end in TableDefs.Line 1.Connect, but I don't know
how to get that in my string.
string = dbs.TableDefs(?????). By the way, thanks for
all your help with this novice Allen.
 
A

Allen Browne

Dan, I don't think I understand what you are asking to do.

You are saying that your database has completely lost the information about
which back end file the tables were connected to. In fact, it does not have
any linked tables: they are all local tables.

Further, you are saying that you do not know which mdb file it used to be
connected to before they all became local tables. And if you did know what
mdb they used to be connected to, what do you want to do: delete all the
local tables, and replace them with links to the back end file instead?

You do not want to pop up a File Open dialog so the user can locate the
appropriate data file. That was the solution I thought you were after.

Presumably you want to run a search on your hard drive and/or network drives
to find all the mdb files, and then examine each one in turn to find out
which one has a data structure that is similar to the local tables in your
database???

Sorry: I have no idea what you are trying to achieve here.
 
D

Dan

Sorry Allen;

One last try. Because my database has a front-end and
back-end, I have code to allow users to connect to a
different or new back-end. This code works! All I want
to do is build a form to tell the user what back-end they
are connected to.
 
A

Allen Browne

If you know the name of any table that is in the back end you want to know
about, you could do that in a form by setting the Control Source of a text
box to this:

=Mid(dbEngine.Workspaces(0).Databases(0).TableDefs("YourLinkedTableNameHere"
).Connect, 11)
 
D

Dan

OK, NOW I understand.

You answered my question about five messages ago and I
was just too stupid to figure it out. Everytime you
said "table", I was thinking "database". Sometimes I
wonder why I didn't retire when the mainframe jobs
started drying up. Thanks again Allen.

Dan
-----Original Message-----
If you know the name of any table that is in the back end you want to know
about, you could do that in a form by setting the Control Source of a text
box to this:

=Mid(dbEngine.Workspaces(0).Databases(0).TableDefs ("YourLinkedTableNameHere"
).Connect, 11)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.


Dan said:
Sorry Allen;

One last try. Because my database has a front-end and
back-end, I have code to allow users to connect to a
different or new back-end. This code works! All I want
to do is build a form to tell the user what back-end they
are connected to.
-----Original Message-----
Dan, I don't think I understand what you are asking to do.

You are saying that your database has completely lost the information about
which back end file the tables were connected to. In fact, it does not have
any linked tables: they are all local tables.

Further, you are saying that you do not know which mdb file it used to be
connected to before they all became local tables. And
if
you did know what
mdb they used to be connected to, what do you want to do: delete all the
local tables, and replace them with links to the back end file instead?

You do not want to pop up a File Open dialog so the
user
can locate the
appropriate data file. That was the solution I thought you were after.

Presumably you want to run a search on your hard drive and/or network drives
to find all the mdb files, and then examine each one
in
turn to find out
which one has a data structure that is similar to the local tables in your
database???

Sorry: I have no idea what you are trying to achieve here.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

I can find the front-end in the Name property, but the
Connect property is "". The front-end and back-end have
been connected previously though because I can find the
back-end in TableDefs.Line 1.Connect, but I don't know
how to get that in my string.
string = dbs.TableDefs(?????). By the way, thanks for
all your help with this novice Allen.

-----Original Message-----
If the tables have been conntected previously, the
Connect property will
contain this value.

If they have not, ask the user where the data is. Three
is an example of how
to do this in solutions.mdb. If you have Access 97, it's
 

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

Top