databasedev.co.uk - database solutions and downloads for microsoft access

Microsoft Access Reports

Add the database name to a printed report in Microsoft Access

It may be useful to display the name of the Microsoft Access database on a report, that you have printed the report from. This way, you can keep track of the source of the report and its data, especially if you have access to many databases.

This is quite a simple procedure and all that is required is as follows:

  1. Open the report in design view.
  2. From the toolbox add a Text Box to the report section you wish to show the information (report header)
  3. In the label for the unbound text box type in what you wish to be displayed
  4. Right click on the unbound text box and choose Properties
  5. On the Data tab, for the control source of the text box add the following expression:

    =Left(CurrentProject.Name,Len(CurrentProject.Name)-4)

In design view this should now look like the following example:

Design view of the report, including the expression to record the database name on the report
Design view of the report, including the expression to record the database name on the report

This is how the report will now look when you view in print preview or print out. You can see the database name, in red stating "which database the report was printed from" (in this case the "Reporting" database):

The report in preview mode, displaying the name of the database that the report is printed from.
The report in preview mode, displaying the name of the database that the report is printed from.