Pathname for current database

Gibbo

New member
Local time
Today, 08:43
Joined
Jan 6, 2006
Messages
9
I maintain an Access 97 database system with a number of front ends and two different back ends (for security reasons). The structure is replicated in different directories as there are training, development and back-up copies as well as the live system. I want the menu page to display the name of the front end that is opened and the path and name of the two back ends, referenced from the current database (front end). To do this, I want to read the directory for the current database as opposed to the current directory which may be different. I can't find this in any VBA reference for MS Access 97; although I used to use the equivalent in Excel using the Get function - as I remember it.

Any help?

Gibbo
 
No it doesn't. Curdir() returns the current directory, not the directory in which the database is stored. Thus if the database has been opened from another directory it returns that rather than the "home" directory of the database - which is what I am trying to read.
 
In access 97 CurrentDb.Name returns the current path & name of the database that you are running from.
 
Searching the forum is a great way to discover and learn the answers to your Access programming questions. I have posted the below commands in numerous posts within this forum.

Getting the location to the current database using Access 2000/2002/2003...

'returns the database file name
CurrentProject.Name

'returns the database path
CurrentProject.Path

'returns the database path and the file name
CurrentProject.FullName

Getting the location to the current database using Access 97...

'returns the database file name
Dir(CurrentDb.Name)

'returns the database path
Left(CurrentDb.Name,Len(CurrentDb.Name)-Len(Dir(CurrentDb.Name)))

'returns the database path and the file name
CurrentDb.Name

'returns the directory that Access [msaccess.exe] is installed in
(SysCmd(acSysCmdAccessDir))
 
The below SQL will list the locations of the linked tables...

Code:
SELECT MSysObjects.ForeignName AS TableName, MSysObjects.Database AS DBLocation, MSysObjects.Type
FROM MSysObjects
WHERE (((MSysObjects.Type)=6))
ORDER BY MSysObjects.ForeignName;

That is also posted in numerous threads within this forum.
 
Thank-you GHudson.

I had tried a variety of options but I was missing the step using Dir(currentdb.name). I have already written the code to pick up the links; but it was dependent on hard coding the "home" directory.

I am new to this and will aim to use the search facilities more. However, on a quick search tonight the only thread that I could get a match on, and which seems, relevant is this one.

Once again, thank-you
 

Users who are viewing this thread

Back
Top Bottom