.\ versus hard file location

brsawvel

Registered User.
Local time
Today, 13:56
Joined
Sep 19, 2007
Messages
256
Hello,

I've been using C:\Program Files\... in my codes to tell the database to locate a file, image, etc.

Someone told me recently that there was a way to use ".\" instead of a hard location in my code to tell the program to look in a folder using the .exe as the starting reference point.

Does anyone know if this works on .mdb or .mde? Does anyone know how it works?
 
This is standard terminology dating from DOS days.

. is your curent directory so .\subdirectory points to a directory based in the current directory.

It should work fine in your database.
 
so how would you go back a folder (directory?)? Is that "..\"?
 
I made those changes in my db, but it didn't recognize the file locations. An example of how I used it was -

Original:
IF image1.Picture = "C:\Program Files\Database\photos\1.bmp" THEN image1.Picture = "C:\Program Files\Database\photos\1Highlight.bmp"

Replaced With:
IF image1.Picture = ".\photos\1.bmp" THEN image1.Picture = ".\photos\1Highlight.bmp"
 
Doesn't work that way, probably. Those are shortcuts. But when Access evaluates them, it might expand them to the full reference. I.e. that leading dot MIGHT be replaced by the C:\... string that normally would take the place of the leading dot.

I prefer to do something early in database startup to locate myself. For instance, if I have a "splash" form or switchboard form, the OnLoad code will do something like

MyDBLoc = CurrentDb.Name

where MyDBLoc is a public string in a general module's declaration area. Once that is loaded, I can parse it a bit more to isolate the device name, path string, DB name, and (of course) .MDB as the file type. Once that is in my public, general declaration area, I can use it to build partial paths as needed. This way, you don't really care that much if you get DOS-like strings or URL-like strings.
 

Users who are viewing this thread

Back
Top Bottom