Current database path name 
Author Message
 Current database path name

Is someone knows how to get the path name of the current database? Thanks



Sun, 12 Sep 1999 03:00:00 GMT  
 Current database path name

  Just read the current database's Name property.

    Function GetDBPathName()
      Dim DB As Database
       Set DB = CurrentDB()
          MsgBox "" & DB.Name
    End Function

  Depending on your version of Access you may need to change the
reference to  CurrentDB/CurrentDB()

Good Luck! Brian_RestonVA

On Wed, 26 Mar 1997 09:51:53 -0800, "Frederic Goulet"

Quote:

>Is someone knows how to get the path name of the current database? Thanks



Sun, 12 Sep 1999 03:00:00 GMT  
 Current database path name

This is defined in a main module:
        Set gdbCurrent = dbengine.workspaces(0).Databases(0)
        gstrPath = gstrDatabasePath()

--------------------------------------------------------------------------

This will get the path of the database

Function gstrDatabasePath ()
On Error GoTo gstrDatabasePathError

    'Declare local variables
        Dim intPosition As Integer
        Dim strDBPath As String
        Dim strCurrentDB As String

    'Parse the database Name
        intPosition = 0
        intPosition = InStr(1, gdbCurrent.Name, "\")
        strDBPath = gdbCurrent.Name
        strCurrentDB = gdbCurrent.Name

        Do While intPosition > 0
            intPosition = InStr(1, strCurrentDB, "\")
            strCurrentDB = Right(strCurrentDB, Len(strCurrentDB) -
intPosition)
        Loop

    'Return the Name of the database
        strDBPath = Left(strDBPath, (Len(strDBPath) - Len(strCurrentDB))
- 1)
        gstrDatabasePath = strDBPath

gstrDatabasePathExit:
    'Exit the procedure
        Exit Function

gstrDatabasePathError:
    'Display the error
        MsgBox "gstrDatabasePath() Error " + Str(Err) + " Line " +
Str(Erl) + ": " + Error$
        Resume gstrDatabasePathExit

End Function

--------------------------------------------------------------------------

This will get the database name

Function gstrDatabaseName ()
On Error GoTo gstrDatabaseNameError

    'Declare local variables
        Dim intPosition As Integer
        Dim strCurrentDB As String

    'Parse the database Name
        intPosition = 0
        intPosition = InStr(1, gdbCurrent.Name, "\")
        strCurrentDB = gdbCurrent.Name

        Do While intPosition > 0
            intPosition = InStr(1, strCurrentDB, "\")
            strCurrentDB = Right(strCurrentDB, Len(strCurrentDB) -
intPosition)
        Loop

    'Return the Name of the database
        gstrDatabaseName = strCurrentDB

gstrDatabaseNameExit:
    'Exit the procedure
        Exit Function

gstrDatabaseNameError:
    'Display the error
        MsgBox "gstrDatabaseName() Error " + Str(Err) + " Line " +
Str(Erl) + ": " + Error$
        Resume gstrDatabaseNameExit

End Function



Tue, 14 Sep 1999 03:00:00 GMT  
 Current database path name

Function DBName ()
Dim DB As Database

Set DB = DBengine(0)(0)
' or in Access 1
'Set DB = CurrentDB()

Debug.Print DB.Name

End Function

Unfortunately you cannot just refer to

DBengine(0)(0).name

If you want to parse out the drive, directory, file name or extension, then
that is a little more work. It's a bit more advanced but if you are ready
for it (make sure you have DebugLibraries=True in you ini file), you can
read the WZLIB library code and will find that there are some functions (eg
wlib_ParseFullPath) that can help with this.

HTH

--
Steve Sarre
SIS
London UK



Quote:
> Is someone knows how to get the path name of the current database? Thanks



Thu, 23 Sep 1999 04:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Path name of current DB

2. Retreive path and folder name of current db

3. Path and file name for current DB

4. show save as dialog with default doc path but current file name

5. ADSI:GetObject network path not found reading info other than the current computer name

6. Retrieve name of current sub/function and name of current module

7. Finding path of current database?

8. current database path

9. How to get path of current database?

10. Path of Current database ?

11. Get current database directory path

12. Setting the path to the path of the current application

 

 
Powered by phpBB® Forum Software