A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

CODE: get current dir of MDB file



 
 
Thread Tools Display Modes
  #1  
Old January 29th, 2008, 04:41 PM posted to microsoft.public.access.reports
A Man
external usenet poster
 
Posts: 29
Default CODE: get current dir of MDB file

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


  #2  
Old January 29th, 2008, 06: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]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:54 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.