Get Number of Records Action

image\Action_Database_Count_Records.jpg

The Get Number of Records action will count the number of records in a query’sSelect List; the number is then saved in a variable.

Note:
This action will NOT return the total number of records in a table, only the total number of records in a Select List. In other words, if the Select List of a Query is a sub-set of a table (i.e. the Query does not select all the records in a table) the number returned is the total number of records in the sub-set.

Setting up the Get Number of Records action:

1. Add the Get Number of Records action to your trigger, as described in adding actions. The Get Number of Records tab will automatically appear when you add the action.

Note:
An On Show trigger on the page normally triggers this action.

2. Click on the down arrow to the right of the Query box to open a list of query’s you have previously created in this publication.

Note:
If the drop down box is empty, you have not previously entered a Database Query action to this publication. You must have created at least one Database Query action in order for this action to work.

3. Use the Variable option to select the name of the variable in which the number of records should be stored – the variable will always contain a number, the value of which will be equal to the number of records in the Select List. Click on the down arrow to the right of the Variable box to open a list of all the variables in your current publication.

Note:
Alternatively, click on the New… button to open the New Variable dialog box where you can create a new variable.

4. Click on the Apply button to save your changes.

Note:
This action is normally used with the Get Current Record Number action to display information to the user in a format similar to:

 Record: 1 of 8 Total Records 

This can be easily achieved by drawing one Text object on a page and inserting the variable name (point 3 above) into the text box – see Example.

Related Topics:

Working with Databases - Overview

Introducing the Database Actions

Showing Records from a Database in Opus

Choosing an Action