Any way to get database directory? 
Author Message
 Any way to get database directory?

I've found a number of really good items in these newsgroups(thanks!), but
now I have a question I haven't seen an answer to.

Q: Is there an API (or any other method) that returns the directory where
the database file (.mdb or .mde) resides? I need to distribute some files
with a database runtime, and the database needs to know where its directory
is to find the files. I can't trust the user to navigate to the directory
correctly.

TIA!



Fri, 10 Aug 2001 03:00:00 GMT  
 Any way to get database directory?
Sandy,
Function GetDBDir()
'returns the path to the current database
Dim db As Database          'database object
Dim tPath As String         'temporary path

'configure the database object
Set db = CurrentDb

'set the temporary path the path to the database
tPath = db.Name

'loop through the temporary path and truncate to each backslash (\)
Do While InStr(tPath, "\") > 0
    GetDBDir = GetDBDir & Left(tPath, InStr(tPath, "\"))
    tPath = Right(tPath, Len(tPath) - InStr(tPath, "\"))
Loop

'close the database object
db.Close

End Function

Regards,
David McTavish



Fri, 10 Aug 2001 03:00:00 GMT  
 Any way to get database directory?
Thanks, I'll try it!


Fri, 10 Aug 2001 03:00:00 GMT  
 Any way to get database directory?
i've never used the particular functions before, but i believe you can
save and restore the values from the windows registry.  look at
getsetting(), and savesetting().  i only know this because someone else
posted the question awhile back, and i remembered it.  funny your last
name is gettings ( Get Settings - haha)
Quote:

> I've found a number of really good items in these newsgroups(thanks!), but
> now I have a question I haven't seen an answer to.

> Q: Is there an API (or any other method) that returns the directory where
> the database file (.mdb or .mde) resides? I need to distribute some files
> with a database runtime, and the database needs to know where its directory
> is to find the files. I can't trust the user to navigate to the directory
> correctly.



Sat, 11 Aug 2001 03:00:00 GMT  
 Any way to get database directory?
Why not create a separate file i.e. Setup.ini
this file would contain any settings required by the program in question
Then when the program starts you can open the ini file, loop through the
text checking the settings as you go and then set the required variables
within the code.

I can supply a working example.

Quote:

> I've found a number of really good items in these newsgroups(thanks!), but
> now I have a question I haven't seen an answer to.

> Q: Is there an API (or any other method) that returns the directory where
> the database file (.mdb or .mde) resides? I need to distribute some files
> with a database runtime, and the database needs to know where its directory
> is to find the files. I can't trust the user to navigate to the directory
> correctly.

> TIA!

Salutations

Nic



Sat, 11 Aug 2001 03:00:00 GMT  
 Any way to get database directory?
Why not, indeed. This is only a solution if the application is deployed to
workstations and each user has a unique ini file.
For network applications the data must be stored in a table, keyed to the
user's system or login name.
There!
--
Gary (MCT, MCPS, MCSD)
http://www.enter.net/~garyl/  for references to good books

ICQ 6375624
Quote:

>Why not create a separate file i.e. Setup.ini
>this file would contain any settings required by the program in question
>Then when the program starts you can open the ini file, loop through the
>text checking the settings as you go and then set the required variables
>within the code.

>I can supply a working example.


>> I've found a number of really good items in these newsgroups(thanks!),
but
>> now I have a question I haven't seen an answer to.

>> Q: Is there an API (or any other method) that returns the directory where
>> the database file (.mdb or .mde) resides? I need to distribute some files
>> with a database runtime, and the database needs to know where its
directory
>> is to find the files. I can't trust the user to navigate to the directory
>> correctly.

>> TIA!

>Salutations

>Nic



Sat, 11 Aug 2001 03:00:00 GMT  
 Any way to get database directory?
Here's another variation that loops through the db.Name backwards to find
the first backslash:

Private Function GetDBPath() As String

    Dim strDBName As String
    Dim lngLength As Long

    strDBName = CurrentDb.Name
    lngLength = Len(strDBName)
    Do Until Mid(strDBName, lngLength, 1) = "\" Or lngLength = 0
        lngLength = lngLength - 1
    Loop
    If lngLength > 0 Then
        GetDBPath = Left(strDBName , lngLength)
    End If

End Function

Dennis

Quote:

>I've found a number of really good items in these newsgroups(thanks!), but
>now I have a question I haven't seen an answer to.

>Q: Is there an API (or any other method) that returns the directory where
>the database file (.mdb or .mde) resides? I need to distribute some files
>with a database runtime, and the database needs to know where its directory
>is to find the files. I can't trust the user to navigate to the directory
>correctly.

>TIA!



Sun, 12 Aug 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Newbie question Getting a directory from drive into database

2. Newbie question Getting a directory from drive into database

3. Getting ALL directories & sub directories

4. Getting Start Menu Directory and Favorites Directory Paths by API

5. Ways to display database information

6. Getting at database objects, not DAO, in an access database through code

7. Getting data from the Active Directory

8. Getting filenames on directory

9. Getting apps current directory

10. Getting values from Active Directory

11. Getting list of files in a directory

12. Getting computer names from Active Directory

 

 
Powered by phpBB® Forum Software