Store backend file path

DBL

Registered User.
Local time
Today, 05:14
Joined
Feb 20, 2002
Messages
659
How can I find and capture the file path for the backend as a variable? I want to save it to a table so I can then do other things with it, including checking the links and saving backups. That I can do, just don't know how to find the backend file path in the first place!
 
You can use this function to get the path

Function GetLinkedDBName(TableName As String)
Dim db As Database
Dim Ret

On Error GoTo DBNameErr
Set db = CurrentDb()
Ret = db.TableDefs(TableName).Connect
GetLinkedDBName = Right(Ret, Len(Ret) - (InStr(1, Ret, "DATABASE=") + 8))
Exit Function

DBNameErr:
GetLinkedDBName = 0

End Function


Then

MyVariable = GetLinkedDBName("MyTableName")

This gives you the path and file name of your backend file.

HTH
John
 
Hi John

Sorry it's taken me so long to get back to this but other things got in the way. Many thanks for your response but I'm afraid I can't get it to work (my problem, not yours!). I've created a module for the function and I added the MyVariable = GetLinkedDBName("tblBackPath") to my splash screens code but I'ts not capturing the back path,. Any ideas?
 
Add a text box to your form and then in the On Open event of the form add the following line


Me.txtYourTextBox= GetLinkedDBName("YourTableName")
 

Users who are viewing this thread

Back
Top Bottom