Define a CHOOSE trigger for your button
- Last Updated: October 12, 2023
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
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:
- Click the Edit Code button to bring up the Section
Editor, and go back to the procedure
enable_UI. - 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
Customerquery, 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 theOrderquery, you do need, so you will go back and get that in a moment. - 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-ENDblock. You can see that the block of code is defined to executeON CHOOSE OF BtnFirst.