Now you need to write some code for the AVM to execute when the user clicks the First button. You can cheat a little here and copy some code you already looked at, because it uses some query syntax that you will not read about in detail until a later section.

To define a CHOOSE trigger for your button:

  1. Click the Edit Code button to bring up the Section Editor, and go back to the procedure enable_UI.
  2. Copy the two statements (five lines of code in all) starting with GET FIRST CustQuery. Select the text by clicking and dragging the mouse over it, then press CTRL+C:

    Why do you select just these lines? The preprocessor value in the first line of the procedure opens the Customer query, and since it is already open when the user clicks a button, you do not need to do that again. Likewise, the fields and other objects in the window are enabled, so you do not need to do that again either. (You might notice that your new BtnFirst button has already been added to the list of things to enable.) And the window has been viewed, so you do not need that statement. However, the statement before that, which opens the Order query, you do need, so you will go back and get that in a moment.

  3. Drop that same code into the trigger to execute when the user clicks the First button. You can get the Section Editor to move to that place in the procedure in two ways:
    • Back in the design window, select the First button by clicking on it, and then select the Edit Code icon again.
    • In the Section Editor, select Triggers as the Section type. This might bring up the correct trigger for you. If it does not, then select BtnFirst from the drop-down list labeled OF:

    In either case you get a starting point for some ABL code defined within a DO-END block. You can see that the block of code is defined to execute ON CHOOSE OF BtnFirst.