Expressions

Earlier in this chapter, you learned how to add a label and set its text. But if you look at the controls on a typical report, you’ll quickly notice that they don’t all use ordinary text. Consider the date or page number information (which appears in the top-right corner of a simple report). Both these details appear in ordinary label controls, but the text looks distinctly different. It starts with an equal (=) sign, which indicates the presence of an expression.

Expressions let text boxes and other controls show dynamic values. No one wants to type in a specific date in a report, because you’d be forced to update it every time you want to make a printout. Instead, you use an expression like =Date(), which tells Access to grab the current date from the computer clock and display that.

Expressions aren’t new. You learned about them with queries on Building filter expressions. However, until now you probably didn’t realize that they’re equally at home in reports. You can add your own expressions to a report to display dynamic data, or perform calculations based on other fields.

Suppose you want to improve the wedding list by combining the first and last names into a compact one-line display. As you learned on Expressions with Text, the & symbol is the ticket for fusing together pieces of text. Here’s the expression you need:

=FirstName & " " & LastName

Note

Refer to Chapter 7 (starting on Calculated Fields) for an overview of expressions, the different types ...

Get Access 2010: The Missing Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.