Use of button to control the execution of the query
When you execute the Dashboard, you will notice that the query results are shown as soon as you finish selecting the employee name and dates, not giving you a chance to change selections before executing the report.
To remedy this situation, we will create a 'Go' button so that you have control over the execution of the query.
- Add a button to the dashboard by clicking the button icon
on the toolbar. A button will then be placed on the form. Move the button to the desired location and adjust the size by using the drag handles.
- Change the variable name of the Button to 'GoButton' on the Properties tab of the DataBlock Designer.
- Change the text displayed on the button to 'Go' by editing the Text property.
- Double-click on the object that displays the query results (the multi-column list box at the bottom), click the Build Query icon
, then select the “Conditional Fields (WHERE) tab.
- In the WHERE clause (that was edited in the previous exercise), click inside the Table field in the next empty column to the right.
- Click the down arrow that appears inside the field and select '<calculated>' from the list.
- Click inside the Field field, then click the ellipses button
that appears inside the field. The SQL Editor will launch.
- In the SQL Editor, click the variableicon
to launch the Pick a variable dialog.
- Choose GoButton from the variable list and click OK.
- Click OK to exit the SQL Editor.
- Click the ellipses button
in the As field, and enter is not null into the SQL Editor.
- Click OK to return to the Build Query. The condition for the Go button has now been added.
- Click OK and Finish, then verify the query to return to the DataBlock Designer.
- Save your changes and click Test
to view the dashboard and test your new button.
Until the button is clicked, the variable representing the state of the button object is null, and the query will not execute. When clicked, the value is no longer null and the query will execute.