Microsoft Office Tutorials and References
In Depth Information
Employing Formatting Tips and Tricks
text box, enter the parameter prompt in square brackets so that it looks
something like the following:
Enter title line ]
✦ Preventing spaces between fields: When you display several fields
in a row, you may not want to leave gaps between them. In a mailing
label or form letter, you may want to print fields containing first names
and last names with only one space between them. To eliminate extra
spaces between fields, regardless of the length of the values in the fields,
concatenate the fields (glue them together) by using the & operator.
(We describe calculated fields and the & operator in Book III, Chapter
2.) Create a text box control, and type an expression in its Control
Source property, such as the following:
= [First Name] & “ “ & [Last Name]
This expression glues together the first name, a space, and the last
name. If the first name is Elvis and the last name is Presley, you end
up with Elvis Presley (the name, anyway).
✦ Using conditional calculations: You can print one thing in some
circumstances and another thing in others by using the IIf() function.
(For more on the IIf() function, see Book III, Chapter 2.) You may
make a report that can print either an invoice or a receipt, depending
on whether the customer has paid. At the top, you include a text box
with an expression in the Control Source property that specifies that
Access should print an invoice or a receipt, depending on the value of
the Paid field. That expression looks something like the following:
= IIf([Paid], “Receipt”, “Invoice”)
✦ Calculating a running sum: You can tell Access to sum the values of a
numeric field showing the total of the current record (a running sum) .
Set the Running Sum property of the text box control displaying that
field to Yes. You may want to include two text box controls for the
numeric field: one to show the value for the current record (with the
Running Sum property set to No) and one to show the running sum
(with the Running Sum property set to Yes).
✦ Hiding duplicate values: If all the records in a group have the same
value for a control, and you want the value to print only the first time
it appears, you can set the Hide Duplicates property of the field to
Yes. This setting is especially useful in tabular reports, in which each
field appears in a separate column.
Don’t use a field name as the control name for a calculated control. When
you create controls, Access names them automatically, although you can
change the names later. If you rename a calculated control, make sure that
the name you assign isn’t the same as that of any field mentioned in the
expression (or any field in the record source of the report). Access gets
confused about whether references to that name are to the field or to the
control, and the report displays an error message.