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.

  1. Add a button to the dashboard by clicking the button icon 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. 
    Dashboard design with the new button added and placed below the two dates.
  2. Change the variable name of the Button to 'GoButton' on the Properties tab of the DataBlock Designer. 
    The variable name for the button has been changed to GoButton (one word, with a captial g and a capital b).
  3. Change the text displayed on the button to 'Go' by editing the Text property.
  4. Double-click on the object that displays the query results (the multi-column list box at the bottom), click the Build Query icon build query icon, then select the “Conditional Fields (WHERE) tab.
  5. In the WHERE clause (that was edited in the previous exercise), click inside the Table field in the next empty column to the right.
  6. Click the down arrow that appears inside the field and select '<calculated>' from the list.
  7. Click inside the Field field, then click the ellipses button ellipses button that appears inside the field. The SQL Editor will launch.
  8. In the SQL Editor, click the variableicon pick a variable icon to launch the Pick a variable dialog.
  9. Choose GoButton from the variable list and click OK.
  10. Click OK to exit the SQL Editor.
  11. Click the ellipses button ellipses button in the As field, and enter is not null into the SQL Editor.
  12. Click OK to return to the Build Query. The condition for the Go button has now been added.
      This image shows the condition that was entered for the Go button.  The is not null condition is used to determine when the button is pressed.
  13. Click OK and Finish, then verify the query to return to the DataBlock Designer.
  14. Save your changes and click Test test dashboard button 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.