Example 3: highlighting rows of data

The DataWindow object in Figure 23-8 is an employee phone list for a company in the U.S. state of Massachusetts. Out-of-state (not in Massachusetts) employees are shown in bold and preceded by two asterisks (**).

Figure 23-8: Data highlighting with asterisks

The sample Employee Phone List has columns for Employee Name and Phone number. Some of the names are preceded by two asterisks and shown in bold face type. A note in bold face at the top states that a double asterisk means out of state.

In the Design view, the detail band includes four controls: the employee last name, a comma, the employee first name, and the phone number. (A computed field that concatenates the last name and first name columns, and separates them with a comma, could be used instead of the first three controls.)

NoteLogic that relies on the state column In this example, you use logic that relies on the state column, so you need to include it in the data source. You can add the column after creating the DataWindow object by modifying the data source. Notice that the state column does not actually appear anywhere in the DataWindow object in Figure 23-8. Values must be available but do not need to be displayed.

To make these controls display in bold with two asterisks if the employee is not from Massachusetts:

  1. Select one of the controls, then use Ctrl + Click to select the other controls.

    The Properties view changes to show the properties that are common to all selected controls.

  2. On the Font page in the Properties view, click the button next to the Bold property.

  3. Enter the following expression in the Modify Expression dialog box and click OK:

    If(state = 'MA', 400, 700)
    

    The expression states that if the value of the state column is MA, use 400 as the font weight. This means employees from Massachusetts display in the normal font. For any state except MA, use 700 as the font weight. This means all other employees display in bold font.

  4. To insert two asterisks (**) in front of the employee name if the employee is not from Massachusetts, add a text control to the left of the employee name with the two asterisks in bold.

  5. With the text control selected, click the button next to its Visible property on the General page in the Properties view.

  6. In the Modify Expression dialog box that displays, enter the following expression and click OK:

    If(state = 'MA', 0, 1)
    

    This expression says that if the state of the employee is MA (the true condition), the Visible property of the ** control is off (indicated by 0). If the state of the employee is not MA (the false condition), the Visible property of the ** control is on (indicated by 1). The asterisks are visible next to that employee's name.

    NoteOther highlighting tips You can use underlines, italics, strikethrough, borders, and colors to highlight information.