Kbase P18744: How to set the SCREEN-VALUE of a COMBO-BOX widget ON the VALUE-CHANGED event of a related COMBO-BOX
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  08/08/2006 |
|
Status: Unverified
GOAL:
How to set the SCREEN-VALUE of a COMBO-BOX widget ON the VALUE-CHANGED event of a related COMBO-BOX widget?
FACT(s) (Environment):
Windows
FIX:
Following is a step-by-step procedure of a sample solution where we use two COMBO-BOX widgets that are populated from two related database tables:
1. Connect to the sports2000 database.
2. Using the AppBuilder, create a new window.
3. Drop two COMBO-BOX widgets on the window.
4. Use the property sheet of the first COMBO-BOX to set the object to
CustomerCombo and the label to Customer Name and set the initial value to
nothing.
5. Use the property sheet of the second COMBO-BOX to set the object to
SalesRepsCombo and the label to Sales Reps Name and set the initial value to
nothing.
6. Insert the following code in the windows MAIN BLOCK section and after the RUN
enable_UI. Statement:
/* ***Populate the Customer Names COMBO-BOX without duplicates***** */
ASSIGN
CustomerCombo = ""
CustomerCombo:DELIMITER = CHR(1).
FOR EACH customer NO-LOCK BREAK BY Customer.Name:
IF LAST-OF(Customer.Name) THEN
CustomerCombo:ADD-LAST(Customer.Name).
END.
/* ***Populate the Sales Rep Names COMBO-BOX without duplicates***** */
ASSIGN
SalesRepsCombo = ""
SalesRepsCombo:DELIMITER = CHR(1).
FOR EACH Salesrep NO-LOCK BREAK BY Salesrep.RepName:
IF LAST-OF(Salesrep.RepName) THEN
SalesRepsCombo:ADD-LAST(Salesrep.RepName).
END.
7. Insert the following code in the VALUE-CHANGED event trigger of the
CustomerCombo COMBO-BOX widget:
DO:
FIND FIRST Customer WHERE Customer.Name = CustomerCombo:SCREEN-VALUE NO-LOCK.
FIND FIRST SalesRep WHERE Customer.SalesRep = Salesrep.SalesRep NO-LOCK.
ASSIGN
SalesRepsCombo:SCREEN-VALUE = Salesrep.RepName.
END.
8. Save the window.
9. Run the window.
Notice that when you select a customer name, the Sales Reps COMBO-BOX will
change to that Customer's existing Sales Rep Name.