How do I get the path of my BackEnd databases?

Lateral

Registered User.
Local time
Today, 00:32
Joined
Aug 28, 2013
Messages
388
Hi guys

I need to be able to display that actual path that contains the database for my FE/BE application.

I can't find where this information is kept. Is there some sort of Access System variable that has this information?

Thanks for any help.

Regards
Greg
 
Thanks Plog,

It works a treat except.....

I am displaying this information on the Status Bar and also in a Msgbox.

It is displaying c:\RPR\BACKEND which is where the database would be stored normally but....

I just tested it on another PC running just the Runtime and it is not being displayed on the status bar or via a testing MSGBOX I have set up if the backend databases are on a network share.

I am using [FONT=&quot]http://www.jstreettech.com/downloads.aspx (The J Street Access Relinker) in order to provide an easy method of pointing to another Backend database and also for when I have installed the Front End on 2 PC's with them pointing to the same Backend database that is located on a file share (eg: Z:)

Any ideas?

Regards
Greg


[/FONT]
 
Last edited:
Hi Plog,

I think that code is way above my "pay grade"! I started getting a headache just looking at it...any other ideas?
 
open the msysobjects table (it may be hidden so you may have to unhide it in file>options>current database>navigation options)

You'll find the path for the relevant table in the database column

If using runtime, you'll need to use a form to display the data since the navigation window is not an option

Alternatively go through the tabledefs collection for the same information
 
Hi CJ

I had no idea that these hidden tables existed!

I'll have a play around and report back.

Regards
Greg
 
FE Path:

CurrentProject.Path

BE Path:

Public Function BEPath() As String

Dim db As DAO.Database
Dim td As DAO.TableDef
Dim pos As Integer
Dim strRet As String
Const CONS_TEXT As String = "DATABASE="

Set db = CurrentDb
For Each td In db.TableDefs
With td
pos = InStr(.Connect, CONS_TEXT)
If pos > 0 And ( _
InStr(.Connect, ".ACCDB") > 0 Or _
InStr(.Connect, ".ACCDE") > o Or _
InStr(.Connect, ".MDB") > 0 Or _
InStr(.Connect, ".MDE") _
) Then
strRet = Mid(.Connect, pos + Len(CONS_TEXT))
Exit For
End If
End With
Next
If strRet = "" Then strRet = CurrentProject.Path
Set td = Nothing
Set db = Nothing
BEPath = strRet
End Function
 
Hi guys

I managed to do what I needed using Dlookup to get the value I needed from the msysobjects table.

Thanks again for your help.

Regards
Greg
 
fwiw, I never use the msysobjects table for anything.

I would use the connect path of any connected table. obviously in some cases you may be using multiple backends, so there may be more than one example.

front end: currentproject.path

backend: mid(currentdb.tabledefs("connectedtable").connect,11)

(this assumes the connect string starts with a semicolonthus. ;database=
arne's code just above seems to indicate that in some cases it may not start with this.
 
If it helps anyone, this is the code I use (credit to Albert Kallal):

Code:
Function strBackEnd() As String

    Dim mytables        As DAO.TableDef
    Dim strTempBack     As String
    Dim strFullPath     As String
    strFullPath = ""
    
    For Each mytables In CurrentDb.TableDefs
       If Left(mytables.Connect, 10) = ";DATABASE=" Then
          strFullPath = Mid(mytables.Connect, 11)
          Exit For
       End If
    Next mytables
    
    strBackEnd = strFullPath
    
End Function
 
We use the following. You would replace "Item Master TBL" with some table in the FE that you know will always be there

Code:
Public Function GetBackendPath()

GetBackendPath = Split(Split(CurrentDb.TableDefs("Item Master TBL").Connect, "Database=")(1), ";")(0)

End Function
 

Users who are viewing this thread

Back
Top Bottom