|Microsoft Office Access 2003
Microsoft Access 97, 2000, and 2002
If you want to display the path or file name of your database in a form or report, you can add a text box control in Design view. Then, set the form or report's ControlSource property so that the text box control retrieves the value of a property of the CurrentProject object. For example, if you want to display the file name of the current database in your report, take the following steps:
Open the report in Design view
- In the Database window, under Objects, click Reports.
- Click the report, and then click Design in the Database window.
Create the text box control
- Click in the section in which you wish to add the text box, for example, the page footer section.
- In the toolbox, click the Text Box tool.
Note If the toolbox is not visible, on the View menu, click Toolbox.
- Drag the pointer in the section to create a text box. If a label appears next to the text box, delete the label.
- Select the text box, and then click Properties on the View menu.
- Click the All tab, and then type the following expression in the ControlSource property box:
- Close the property sheet.
- On the View menu, click Print Preview to see the results.
The Name property of the CurrentProject object returns the file name for the database. For example, for the Northwind Traders sample database that ships with Access, the Name property returns Northwind.mdb.
You can also display the file name without the file extension, the file name with the complete path, or just the path to the file. The following table shows how to do each of these.
||Use this expression:
|File name without the file extension
|File name with the complete path
|Just the path