How to set working directory at runtime? 
Author Message
 How to set working directory at runtime?

Using Access 97

I use a number of different Access databases spread across various directories!

On some of them I need the current working directory to be the same as where the database is - but
cannot find a way of doing this!

The only setting I can find is in Tools | Options | General | Default database folder but this sets
it the same for all databases! - even setting Working Dir for the shortcut is ignored!

Please don't tell me this is yet another classic Microsoft mindless ommission!

Thanks

A.H



Sat, 28 Jul 2001 03:00:00 GMT  
 How to set working directory at runtime?
ChDir left(currentdb.Name, len(currentdb.Name) - len(dir(currentdb.Name)))
should set the current directory to the directory of the database.

HTH
Lembit


Quote:
>Using Access 97

>I use a number of different Access databases spread across various
directories!

>On some of them I need the current working directory to be the same as

where the database is - but
Quote:
>cannot find a way of doing this!

>The only setting I can find is in Tools | Options | General | Default

database folder but this sets
Quote:
>it the same for all databases! - even setting Working Dir for the shortcut
is ignored!

>Please don't tell me this is yet another classic Microsoft mindless
ommission!

>Thanks

>A.H



Sat, 28 Jul 2001 03:00:00 GMT  
 How to set working directory at runtime?
Try ChDir

Alden

Quote:

>Using Access 97

>I use a number of different Access databases spread across various
directories!

>On some of them I need the current working directory to be the same as

where the database is - but
Quote:
>cannot find a way of doing this!

>The only setting I can find is in Tools | Options | General | Default

database folder but this sets
Quote:
>it the same for all databases! - even setting Working Dir for the shortcut
is ignored!

>Please don't tell me this is yet another classic Microsoft mindless
ommission!

>Thanks

>A.H



Sat, 28 Jul 2001 03:00:00 GMT  
 How to set working directory at runtime?
Hi AH,

Just what are you trying to do?  Try looking up CHDir in Help.  But I
haven't yet ever had the need to use it in Access at all.

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

:Using Access 97
:
:I use a number of different Access databases spread across various
directories!
:
:On some of them I need the current working directory to be the same as
where the database is - but
:cannot find a way of doing this!
:
:The only setting I can find is in Tools | Options | General | Default
database folder but this sets
:it the same for all databases! - even setting Working Dir for the shortcut
is ignored!
:
:Please don't tell me this is yet another classic Microsoft mindless
ommission!
:
:Thanks
:
:A.H
:



Sat, 28 Jul 2001 03:00:00 GMT  
 How to set working directory at runtime?
Alden,

This is how I get the directory of the database.

First,  set a global dim in a module assigning the database name (see
below):

Global Const AppDBName = "\yourdatabasename.mdb"

Then I have a function whish uses the name property of a database
object.  This will pull the directory and name of the database.  I
then pull out just the directory part.

Hope this helps

Bill

Function GetAppDir() As String
Dim MyDB As Database
Dim TmpStr As String
Dim Pos As Integer

    On Error GoTo Err_GetAppDir
    GetAppDir = ""
    Set MyDB = CurrentDb

    'get current database directory
    'if app database names changes change next line
    TmpStr = MyDB.Name
    Pos = InStr(1, TmpStr, AppDBName)
    GetAppDir = Mid(TmpStr, 1, Pos)

Exit_GetAppDir:
    Set MyDB = Nothing
    Exit Function

Err_GetAppDir:
    MsgBox Error$
    Resume Exit_GetAppDir

End Function

On Tue, 9 Feb 1999 16:45:43 -0500, "Alden Streeter"

Quote:

>Try ChDir

>Alden


>>Using Access 97

>>I use a number of different Access databases spread across various
>directories!

>>On some of them I need the current working directory to be the same as
>where the database is - but
>>cannot find a way of doing this!

>>The only setting I can find is in Tools | Options | General | Default
>database folder but this sets
>>it the same for all databases! - even setting Working Dir for the shortcut
>is ignored!

>>Please don't tell me this is yet another classic Microsoft mindless
>ommission!

>>Thanks

>>A.H

-------------------------------------------------------------------------
To reply by e-mail please remove .nospamplease from the end of my e-mail.

Thanks
-------------------------------------------------------------------------



Tue, 31 Jul 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. finding/setting the directory I'm working in

2. Setting Working Directory

3. how do I set Working Directory?

4. Setting working directories for apps launched with SHELL

5. Set Working Directory

6. Setting Working Directory?

7. Project 98: Set work time fro a set of days

8. Default directory for text files at runtime versus design time

9. Accessing Directories at runtime, Prgoram Files and app.path question

10. Shell (start xxxxx) not working for full Windows-path directory files (works for 8-character directory paths)

11. set directory into which document will have to be saved by user

12. Registry Setting to Change Save As Directory

 

 
Powered by phpBB® Forum Software