|
-
October 22nd, 2001, 08:53 AM
#1
Access 97
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
Nicolas Bohemier
-
October 22nd, 2001, 09:05 AM
#2
Re: Access 97
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]
-
October 22nd, 2001, 09:58 AM
#3
Re: Access 97
In access.. I'll check with currentDB.. But CurrentDB returns a database object.
Nicolas Bohemier
-
October 22nd, 2001, 10:40 AM
#4
Re: Access 97
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]
-
October 22nd, 2001, 01:46 PM
#5
Re: Access 97
Thx this works great ! I just needed a hint but you gave me the code. thx.
Nicolas Bohemier
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|