Add the database name to a report in Access

Applies to
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    

  1. In the Database window, under Objects, click Reports.
  2. Click the report, and then click Design in the Database window.

Create the text box control    

  1. Click in the section in which you wish to add the text box, for example, the page footer section.
  2. In the toolbox, click the Text Box tool.

 Note   If the toolbox is not visible, on the View menu, click Toolbox.

  1. Drag the pointer in the section to create a text box. If a label appears next to the text box, delete the label.
  2. Select the text box, and then click Properties on the View menu.
  3. Click the All tab, and then type the following expression in the ControlSource property box:


  1. Close the property sheet.
  2. 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.

To display: Use this expression:
File name without the file extension =Left(CurrentProject.Name,Len(CurrentProject.Name)-4)
File name with the complete path =CurrentProject.FullName
Just the path =CurrentProject.Path
Applies to:
Access 2003