View Single Post
  #2  
Old January 29th, 2008, 05:07 PM posted to microsoft.public.access.reports
Marshall Barton
external usenet poster
 
Posts: 5,361
Default CODE: get current dir of MDB file

A Man wrote:

I will be posting a few short snippets of code. Many of you coders
already know these, but they should benefit other people as well.

Here is code to find the current directory of the MDB file you currently
have open. This is useful for saving output files (like report PDFS,
text files, etc) to the same dir as your MDB file.

It returns the current directory with a trailing backslash.

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


In A2002and later, you can use CurrentProject.Path

--
Marsh
MVP [MS Access]