When I sit down to consult with someone on an existing database, one of the first things I want to know is, “where in the file system does this live?” Most end-users have no idea. They launch the database from the list of recently used databases that is displayed on the Access 2007 startup screen. That list is handy, and much improved from previous versions, in that it gives you the database name and, if you hover the link, the full path. There’s no way to copy the path so you can paste it into the address bar of a Windows Explorer window, but at least you can find it.
But why not put the path on a form in the database itself? It can fit nicely into the footer or on an “about this database” form, if you have one. And it’s easy as can be, here are the steps:
- Choose a form, enter Design View, and insert a new Text Box control (from the Controlls group of the Design tab on the Ribbon)
- Right-click the control and choose Properties from the context menu
- Click the All tab of the Property Sheet pane
- Change Name to
txtLocation
- Change Control Source to
=[currentProject].[fullname]
- Change Locked to
Yes
- Exit Design View and test your form
You’ll have to adjust the width of the text box to accommodate long paths. I ended up reducing the font size and deleting the label entirely so that I could get it all in the footer of a form. I think I’m going to add this field to all the databases that I regularly work on. It’s incredibly handy to be able to see the path at a glance, especially when you’re working on more than one at a time, and it might (I hope) help end-users understand where their files live.
If you’re troubleshooting an existing database, and want to quickly determine the path, you can do so by pressing Alt+F11
, to launch the VBA editor, typing ?currentproject.FullName
into the Immediate window, and pressing return.
[Update:] If you just want the filename, use =[currentProject].[Name]
How can I limit the characters I have on a text box that I have showing the file name? My text box control source is “=currentproject.name” and it returns with the .accdb on the end. Is there a way to take the file path off of the name?
Do you mean take the file extension off the name? Sure. You’d do this:
=Left(CurrentProject.Name,Len(CurrentProject.Name)-4)
How about
=split(currentproject.Name,”.”)(0)
No need to worry about length of extension.
I added a secondary text box, containing >>>
=Mid([txtLocation],52,(Len([txtLocation])-57)) & “:”
This accounts for the file location on the server and omits the .accdb on the end.