Click to See Complete Forum and Search --> : Access 97
Boumxyz2
October 22nd, 2001, 08:53 AM
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
Iouri
October 22nd, 2001, 09:05 AM
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
iouri@hotsheet.com
Boumxyz2
October 22nd, 2001, 09:58 AM
In access.. I'll check with currentDB.. But CurrentDB returns a database object.
Iouri
October 22nd, 2001, 10:40 AM
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
iouri@hotsheet.com
Boumxyz2
October 22nd, 2001, 01:46 PM
Thx this works great ! I just needed a hint but you gave me the code. :) thx.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.