Home  |  About  |   Search   

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

RunCommand Constants

Terms of Use


 

General: Path and Folder location for databases

Author(s)
Terry Kreft &
Ken Getz

The Name property of the database object holds this information. For example, typing

?CurrentDB.Name
in the Debug window will return the path and filename of the currently open database.

To return the directory, use this function.

'******************** Code Begin ****************
'Code courtesy of
'Terry Kreft & Ken Getz
'
Function CurrentDBDir() As String
Dim strDBPath As String
Dim strDBFile As String
    strDBPath = CurrentDb.Name
    strDBFile = Dir(strDBPath)
    CurrentDBDir = Left$(strDBPath, Len(strDBPath) - Len(strDBFile))
End Function
'******************** Code End ****************

To return just the database name, use Dir$

'*************** Code Start *****************
Dir$( CurrentDB.Name )
or
Dir$( strFilePath )
'*************** Code end  *****************

1998-2009, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer