Navigation

3/02/2013

MS Access report - how to do numbering rows


Microsoft access reports, how to create numbered rows.

http://office.microsoft.com/en-us/access-help/counting-in-reports-HA001137763.aspx

Counting (numbering) the items

Sometimes you want to number the items in your report. For instance, in the Sales by product report, you might want "1" to precede the first item in a product group, "2" to precede the second item, and so on. When the next product group begins, the counting starts over, and "1" precedes the first item. I discussed a technique for doing this in the "Summing in reports" article, in the section Tip: Numbering the rows. Because it's a common request related to counting in reports, I'll also revisit it briefly here.

Numbering the items in a report

You can number the items in your report by using a calculated control and the RunningSum property. First, you create a text box and set its ControlSource property to =1.

Then, you set the RunningSum property for the text box. If you want the numbering to start over for each group, set the property to Over Group. If you want to accumulate a running sum for the entire report, set the property to Over All. For more information about running sums and the RunningSum property, see the section Calculating running sums (cumulative totals), in the "Summing in reports" article.

The expression sets the value of the text box control to "1". Because the RunningSum property is used to accumulate the value, the value in the text box is increased by one for every row. The Sales by Product with Running Sum and Numbered Rows report, in the sample database, demonstrates this technique. Entering a period (.) in the Format property box appends a period to the end of the number.

For detailed step-by-step instructions for numbering the items, see the following expandable section:

HideStep-by-step: How to number the items in a report

To 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.
To create the text box control

  1. In the Detail section, click where you want the number to appear.
  2. In the Toolbox, click the Text Box tool.
 Note   If the Toolbox is not visible, on the View menu, click Toolbox.
  1. In the Detail section of the report, drag the pointer to create a text box, making sure that it's wide enough to accommodate the largest item number. For example, if you will likely have one hundred orders, you will need space for at least three characters (100). 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 txtItemNumber in the Name property box.
  4. Click the Data tab, and then select Over Group in the Running Sum property box.
  5. Type =1 in the Control Source property box.
  6. Click the Format tab, and then type #. in the Format property box.
  7. Close the property sheet.
  8. On the File menu, click Save and then close the report.

No comments:

Post a Comment