CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Access 97

  1. #1
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    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

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    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]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: Access 97

    In access.. I'll check with currentDB.. But CurrentDB returns a database object.

    Nicolas Bohemier

  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    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]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    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
  •  





Click Here to Expand Forum to Full Width

Featured