Coding path name - MDB file may move locations

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've not programmed in a few, but I remember that in VB one can use a short
name (e.g. AppPath) to code the file path name for your application
("c:\windows\system"). That way if the program should be moved, let's say to
the network, you don't need to hard code the file path name.

Can that also be done in Access? Specifically, I've designed an application
for tracking Items. Each record has a picture of that item that
automatically changes on each record. The app is store in the Main directory
and pics are in a subdirectory Pics. Now I need to move the app to the
network or to home and the path for the pics is currently hard coded.
Thanks for the help.
 
Hi Eric,

If you want to return the directory path where the application is running
from, you can use:

CurrentProject.Path

If you are looking to return the full directory path, including the file
name, then you can use:

CurrentProject.Application.CurrentDb.Name

If those seem too fragile for you, you could also create a table for storing
directory paths, one for the front end, one for the back end, for the
pictures folder, etc. Then you can just do DLookups and store them in a
variable at start up. I have done that a couple of times and it works great.

Lance
 
Thanks - that worked.


LTofsrud said:
Hi Eric,

If you want to return the directory path where the application is running
from, you can use:

CurrentProject.Path

If you are looking to return the full directory path, including the file
name, then you can use:

CurrentProject.Application.CurrentDb.Name

If those seem too fragile for you, you could also create a table for storing
directory paths, one for the front end, one for the back end, for the
pictures folder, etc. Then you can just do DLookups and store them in a
variable at start up. I have done that a couple of times and it works great.

Lance
 
Back
Top