Topics: Hands-On 12: Global variable, trigger
(when-new-form-instance)
Now, your client
notice it would be better for them if they could get to specific product's price
rather than entire table. They want you to add more functionality to their
application to display only current item information.
The current
product would be defined by the position of your cursor.
You have been
assigned to modify your application to query only pricing information for a
product whenever your current cursor position is.
You will learn how
to: use and assign global variable, pass global variable from one form to
another, use global variable to execute query base on that parameter, create and
use "WHEN-NEW-FORM-INSTANCE" trigger.
|
More Resources by
Google: |
|
|
|
|
Save the “Customer
orders” Form name as version 12.
Save the “Product
Price Data Entry” Form name as version 2.
Change the
application to query all the product prices for an item that the cursor is on.
Expand the “Product
Price Data Entry” Form.
Select “Data
Blocks.”
Create a new data
block manually.
Change its name.
Open it's property
palette.
Change "Database
Data Block" to "NO."
Close the window.
Create a new item.
Open it's property
palette.
Change the "name"
item to “TEMP_VALUE.”
Change its datatype.
Change "database
item" to “NO.”
Close the window.
Select “Prodid” on
the price data block; and open its property palette.
For “Copy Value
From Item” type "control_block.temp_value."
Close the window.
This shows where
the “temp_value” item is coming from.
Create a
"WHEN-NEW-FORM-INSTANCE" trigger at Form level.
Type “W” and “N”
and select the trigger.
Move the global
prodid item value into the temp_value item.
Then go to the
“price” data block and execute the query function.
Compile the trigger
and close the window.
Highlight the Form
and save it. Then compile it.
On the other Form,
right click on “push button” to choose “Smart Trigger” and select the
"WHEN-BUTTON-PRESSED" trigger.
Change the program
name to the new version (version 2).
Move the product id
item value into the global product id item.
Compile the trigger
and then close the window.
Run the
application.
Click on “Execute
Query.”
Navigate through
the application.
Highlight a product
id and then click on the “Product Price Data Entry” push button.
Now, you only see
information about that specific product id not all the products.
Repeat the process
for some other items.
Minimize the
"Product Price Data Entry" window.
Navigate through
some other application's functions.
Then, close all the
windows and save the changes.
Now, you should
practice this over and over, until you become a master at it.
Good Luck.
|