NUM-RESULTS ( query-name )
|
DEFINE VARIABLE curr-rec AS ROWID NO-UNDO.
DEFINE VARIABLE status-ok AS LOGICAL NO-UNDO. DEFINE VARIABLE threshold NO-UNDO LIKE Customer.CreditLimit INITIAL 25000. DEFINE BUTTON no-orders-custs LABEL "No Orders". DEFINE BUTTON hi-cred-custs LABEL "High Credit". DEFINE QUERY qry FOR Customer. DEFINE BROWSE brws QUERY qry DISPLAY Customer.CustNum Customer.Name Customer.Country Customer.CreditLimit WITH 10 DOWN MULTIPLE. FORM brws SKIP(1) no-orders-custs hi-cred-custs WITH FRAME brws-frame. FORM threshold WITH FRAME thresh-frame VIEW-AS DIALOG-BOX TITLE "Set Threshold" SIDE-LABELS. ON CHOOSE OF no-orders-custs DO: /* Select those customers with no orders. */ status-ok = brws:DESELECT-ROWS(). HIDE MESSAGE. FOR EACH Customer NO-LOCK WHERE NOT CAN-FIND(FIRST Order OF Customer): /* Position query to this record and then select row in browse. */ curr-rec = ROWID(Customer). REPOSITION qry TO ROWID curr-rec. status-ok = brws:SELECT-FOCUSED-ROW(). IF NOT status-ok THEN MESSAGE "Could not select row.". END. /* Report number of selected rows and position to first selected. */ MESSAGE brws:NUM-SELECTED-ROWS "of" NUM-RESULTS("qry") "rows have been selected.". IF brws:NUM-SELECTED-ROWS > 0 THEN status-ok = brws:SCROLL-TO-SELECTED-ROW(1). END. /* ON CHOOSE OF no-orders-cust */ ON CHOOSE OF hi-cred-custs DO: /* Select customers with high credit limits. */ status-ok = brws:DESELECT-ROWS(). HIDE MESSAGE. /* Get CreditLimit threshold value. */ UPDATE threshold WITH FRAME thresh-frame. FOR EACH Customer NO-LOCK WHERE Customer.CreditLimit >= threshold: /* Position query to this record and then select row in browse. */ curr-rec = ROWID(Customer). REPOSITION qry TO ROWID curr-rec. status-ok = brws:SELECT-FOCUSED-ROW(). IF NOT status-ok THEN MESSAGE "Could not select row.". END. /* ON CHOOSE OF hi-cred-custs */ /* Report number of selected rows and position to first selected. */ MESSAGE brws:NUM-SELECTED-ROWS "of" NUM-RESULTS("qry") "rows have been selected.". IF brws:NUM-SELECTED-ROWS > 0 THEN status-ok = brws:SCROLL-TO-SELECTED-ROW(1). END. OPEN QUERY qry PRESELECT EACH Customer. ENABLE ALL WITH FRAME brws-frame. WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. |