473,729 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Directory of Current DB

Is there a way that I would be able to get the current directory of the
database I am working in.

Example: If my database were in "C:\MyDocs\MYDB .mdb" then I would like the
code to return "C:\MyDocs\ "

thanks

T Martin
Nov 13 '05 #1
9 27577
T Martin wrote:
Is there a way that I would be able to get the current directory of the
database I am working in.

Example: If my database were in "C:\MyDocs\MYDB .mdb" then I would like the
code to return "C:\MyDocs\ "


Function ourPath() As String
Dim cRes As String
Dim nPos As Long
cRes = CurrentDb.Name
nPos = Len(cRes)
Do Until Right(cRes, 1) = "\"
nPos = nPos - 1
cRes = Left(cRes, nPos)
Loop
ourPath = cRes
End Function

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2
Bas' solution will work for any version of Access.

From Access 2000 onward, you can just use:
Left(CurrentPro ject.FullName, InstrRev(Curren tProject.FullNa me, "\"))

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bas Cost Budde" <b.*********@he uvelqop.nl> wrote in message
news:cn******** **@news2.solcon .nl...
T Martin wrote:
Is there a way that I would be able to get the current directory of the
database I am working in.

Example: If my database were in "C:\MyDocs\MYDB .mdb" then I would like
the
code to return "C:\MyDocs\ "


Function ourPath() As String
Dim cRes As String
Dim nPos As Long
cRes = CurrentDb.Name
nPos = Len(cRes)
Do Until Right(cRes, 1) = "\"
nPos = nPos - 1
cRes = Left(cRes, nPos)
Loop
ourPath = cRes
End Function
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea

Nov 13 '05 #3
"T Martin" <ma********@cha rter.net> wrote:
Is there a way that I would be able to get the current directory of the
database I am working in.

Example: If my database were in "C:\MyDocs\MYDB .mdb" then I would like the
code to return "C:\MyDocs\ "

thanks

T Martin

The following will break it down to:

"C:\MyDocs\MYDB .mdb"
"C:\MyDocs\ "
"MYDB.mdb"

Function CurrentDBDir() As String

Dim strDBPath As String, strDBFile As String

strDBPath = CurrentDb.Name
strDBFile = Dir(strDBPath)

CurrentDBDir = strDBPath & vbCrLf & _
Left(strDBPath, Len(strDBPath) - Len(strDBFile)) & vbCrLf &
_
strDBFile

End Function
--
»«»«»« Graham »«»«»«
Nov 13 '05 #4
strCurrentDir = Left(strDB, Len(strDB) - Len(Dir(strDB)) )
Nov 13 '05 #5
strDB = CurrentDb.Name
strCurrentDir = Left(strDB, Len(strDB) - Len(Dir(strDB)) )
Nov 13 '05 #6
Johan wrote:
strDB = CurrentDb.Name
strCurrentDir = Left(strDB, Len(strDB) - Len(Dir(strDB)) )


Clever! to subtract the filename, as it were. I'll stick that in my toolbox.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #7
Or: CurrentProject. Path

- Steve

"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:41******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Bas' solution will work for any version of Access.

From Access 2000 onward, you can just use:
Left(CurrentPro ject.FullName, InstrRev(Curren tProject.FullNa me, "\"))

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

Nov 13 '05 #8
Thanks, Steve

Doesn't get much simpler than that!

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Stephen K. Young" <s k y @ stanleyassociat es . com> wrote in message
news:30******** *****@uni-berlin.de...
Or: CurrentProject. Path

Nov 13 '05 #9
Thanks for all the options

"T Martin" <ma********@cha rter.net> wrote in message
news:CU******** ***@fe12.lga...
Is there a way that I would be able to get the current directory of the
database I am working in.

Example: If my database were in "C:\MyDocs\MYDB .mdb" then I would like the
code to return "C:\MyDocs\ "

thanks

T Martin

Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
2478
by: Dan Nash | last post by:
Hi guys I have a page that is *supposed* to list the directories on the server. Here's the code... folderspec = server.MapPath("./images/") set fso = CreateObject("Scripting.FileSystemObject") set fold = fso.GetFolder(folderspec) for each subfolder in fold.subFolders Response.Write(subfolder.name & "<br>")
3
107055
by: Daniel | last post by:
How do you get the current directory of the actual .exe file (not the file name but the directory it is in) ? These do not work: System.IO.Directory.GetCurrentDirectory() - returns system directory not current directory of .exe System.Environment.CurrentDirectory - returns system directory not current directory of .exe System.Reflection.Assembly.GetExecutingAssembly().Location - returns the file name of the current binary
11
15306
by: kk | last post by:
Can any function tell the compiled program executing path? after using the program to open a file from MFC dialog box, the path changes. thks in advance.
4
6353
by: First Tiger | last post by:
Is there a default function or global variable that will allow me to derive the location of my install? I'm trying to store my system settings file from a persistent location. I know that I can set it through code but I want the option to install the same application multiple times on the same computer so I can foresee that being an issue. Any help or direction would be greatly appreciated. Sincerely, FT
3
8666
by: Progman | last post by:
I use Visual Studio 2005 When I run msgbox Curdir(), I get the visual studio directory. This problem seems to be only in the VB part. In the ASP, we use ~/etc... to access files. Why I dont get my project directory?
18
23791
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample code/examples? Thanks in advance, Arthur
3
3187
by: Chris Mellon | last post by:
This appears to be a change in behavior from Python 2.4 to Python 2.5, which I can't find documented anywhere. It may be windows only, or related to Windows behavior. In 2.4, the current directory (os.curdir) was on sys.path. In 2.5, it appears to be the base directory of the running script. For example, if you execute the file testme.py in your current working directory, '' is on sys.path. If you execute c:\Python25\Scripts\testme.py,...
11
6528
by: greg | last post by:
Hi all, Is there a way to get the current theme name at design time? I'm trying to write a custom control for which I need to use images from the current theme. I have asigned a theme to the page as well as in the web.config. The control looks ok at run time but when viewed in the Visual Studio designer it cannot pick up the current theme.
3
8242
by: duyanning | last post by:
I have written a pyhton script that will process data file in current working directory. My script is in an different directory to data file. When I debug this script using pdb within emacs, emacs will change the current working directory to the directory which include the script, so my script cannot find the data file. I think this is the problem of emacs because when I start pdb from console directly, it will not change current...
2
2625
by: Kakkanattu | last post by:
Hi, In desktop application, we use different ways to get the current execution directory. I. AppDomain.CurrentDomain.BaseDirectory II. Environment.CurrentDirectory III. Directory.GetCurrentDirectory() IV. Assembly.GetExecutingAssembly().Location Can u please help me to know the difference of all these? Also is there any other way to get the current directory other than the above?
0
8913
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.