Remain in the field till the right value is entered

chenthil

New Member
hi there
I have written a trigger to match the PO ordered qty and Requisition qty.
I need the cursor to remain in the qty ordered field till the right value is entered
How do i do this

Cheers
Chenthil
 

chenthil

New Member
WE dont know the value...the control value is in one table and the user enters the value in order field...If the qty exceeds the control value, all the trigger has to do is display the error message and ask the user to enter the value again.

The message gets displayed but the cursor does not go back to order qty field
this is the code
{mfdtitle.i}
define vari a as char.
ON ASSIGN OF pod_det.pod_qty_ord
do:
find first req_det where req_nbr = pod_det.pod_req_nbr No-lock no-error.
if avail req_det then
do:
IF pod_qty_ord > req_det.req_qty THEn
DO:
MESSAGE "Qty exceeds requisition qty".
< I need the cursor to remain in qty field after this message>
END.
END.
end.
REPEAT:
{gprun.i ""popomt.p""}
leave.
END.

Hope this is clear
cheers
chenthil
cecsno said:
If you know what the value is, why do you want the user to enter it?
 
That's a database trigger not a UI trigger. This trigger is fired when the new value is being written into the table, not when the user is editing the value in a form. Usually, new values are not written to the table until the form is committed (e.g. you click OK).

So you can either, stick with what you have and just give focus back to the offending field:

IF pod_qty_ord > req_det.req_qty THEN
DO:
MESSAGE "Qty exceeds requisition qty".
APPLY "ENTRY" TO pod_qty_ord.
END.

Or you can setup an "ON LEAVE" trigger for the field. Whenever the field loses focus, the trigger will fire. But... it will also fire if the end-user cancels the form so your trigger code should only perform its validation when the Cancel button hasn't been pressed:

ON LEAVE OF pod_qty_ord
DO:
IF NOT v-cancel-pressed THEN
DO:
IF INPUT pod_qty_ord > req_det.req_qty THEN
DO:
MESSAGE "Qty exceeds requisition qty".
RETURN NO-APPLY.
END.
END.
END.
 
Top