Vladislav Moltchanov wrote:
Salad wrote:
I don't understand you want. If you want the path/filename of the
current mdb, use
Currentdb.name
Or are you saying you have a front end and you might want to work on
backend mdbs in other directories and you want to set connections to
those tables?
You have understood me correctly.
My concern using CurrendDb.name was that in Access97( I still have to
use this for some old projects) the returned value may contain "~". And
I haven't found the ultimate confirmation that this is just a feature of
Access97, not some system options settings, so that some of my customers
running access2000 wouldn't have this short name version as retune value
for CurrendDb.name.
REading your other response, you want the path. Here is something to try
Function GetPath()
Dim strPath As String
Dim intFor As Integer
strPath = CurrentDb.Name
For intFor = Len(strPath) To 1 Step -1
If Mid(strPath, intFor, 1) = "\" Then
GetPath = Left(strPath, intFor)
Exit For
End If
Next
MsgBox strPath
End Function
You could then get the path like
Dim strMDBPath As String
Dim strMDBPath = GetPath()
Thus if your filename of Currentdb.Name =
C:\AccessApps\Development\Market~1.MDB
the result in the messagbox is
C:\AccessApps\Development\
The ~ in the filename may really be the name of the MDB because of the
way it was saved/copied. But Access 97 does recognize long names in
Paths so you don't need to concern yourself that it will be looking for
C:\Access~1\Develo~1\Market~1.MDB
when using Currentdb.name