brsawvel
11-12-2007, 05:28 AM
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?
Rabbie
11-12-2007, 05:31 AM
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.
brsawvel
11-12-2007, 07:27 AM
so how would you go back a folder (directory?)? Is that "..\"?
Rabbie
11-12-2007, 08:20 AM
so how would you go back a folder (directory?)? Is that "..\"?
Thats correct. ..\ is the parent directory.
brsawvel
11-12-2007, 05:58 PM
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"
The_Doc_Man
11-12-2007, 09:24 PM
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.