I would like to know if there's a way to know from which directory the mdb file was opened.. I don't want to hardcode a path for the save file.
Is there any way to know ?
Thanks in advance
Nic
Printable View
I would like to know if there's a way to know from which directory the mdb file was opened.. I don't want to hardcode a path for the save file.
Is there any way to know ?
Thanks in advance
Nic
Are you doing it in VB or Access? If it is VB you already know the directory of mdb. Otherwise you won't be able to open the connection.
If it is Access, I believe CurrentDb will give the path.
Iouri Boutchkine
[email protected]
In access.. I'll check with currentDB.. But CurrentDB returns a database object.
this function will return the whole path
Public Function GetDBDir() As String
On Error GoTo GetDBDirErr
Dim dbsDbCurrent As DAO.Database
Dim strDbName As String
Dim strProcName As String
strProcName = "GetDBDir"
Set dbsDbCurrent = CurrentDb
strDbName = dbsDbCurrent.Name
Do While Right$(strDbName, 1) <> "\"
strDbName = Left$(strDbName, Len(strDbName) - 1)
Loop
strDbName = Left$(strDbName, Len(strDbName) - 1)
GetDBDir = UCase$(strDbName)
GetDBDirDone:
On Error GoTo 0
Exit Function
GetDBDirErr:
Select Case Err
Case Else
MsgBox "Error#" & Err.Number & ": " & Err.Description, _
vbOKOnly + vbCritical, strProcName
Resume GetDBDirDone
End Select
End Function
Iouri Boutchkine
[email protected]
Thx this works great ! I just needed a hint but you gave me the code. :) thx.