我想根据搜索框中的输入过滤结果,我会解释它应该如何工作
代码:
for each customer where customer.no = num no-lock:
tmpname.name = customer.name
tmpname.no = customer.no
end.
if num = "" then
for each customer no-lock:
create tmptable
tmpname.name = customer.name
tmpname.no = customer.no
end.
上表将显示所有公司的结果,
此表单将提示customer.no
form num
customer.no
with frame f1.
update num with frame f1.
现在,我不知道如何将这个数字传回第一个“FOR EACH”。过滤搜索仅针对给定的客户编号。非常感谢您的帮助。提前谢谢。
答案 0 :(得分:1)
我认为这就像你用文本描述的那样(但不是代码):
define variable cNum as integer no-undo.
define query q for customer.
define browse b query q display customer.custNum customer.name with 10 down.
form b with frame custList row 1 column 1.
form
cNum
with
frame updCustNum
column 50
row 1
.
on "s" anywhere do:
apply "entry" to cNum in frame updCustNum.
return no-apply.
end.
on "go", "enter" of cNum in frame updCustNum do:
cNum = integer( self:screen-value ).
close query q.
open query q for each customer no-lock where customer.custNum = cNum.
apply "entry" to b in frame custList.
return no-apply.
end.
open query q for each customer no-lock.
enable cNum with frame updCustNum.
enable b with frame custList.
apply "entry" to b in frame custList.
wait-for "close" of this-procedure.
return.
答案 1 :(得分:0)
我真的不是100%肯定你的要求,但你可以(应该)把你的逻辑放在一个程序中,甚至是一个单独的程序,在特定的事件上调用它(按钮点击,程序启动或你选择的任何东西) )。
PROCEDURE searchCustomer:
DEFINE INPUT PARAMETER piCustomerNo AS INTEGER NO-UNDO.
DEFINE OUTPUT PARAMETER TABLE FOR tmpname.
IF piCustomerNo = 0 THEN DO:
FOR EACH customer NO-LOCK TABLE-SCAN: /* TABLE-SCAN only works in version 11.something and forward */
CREATE tmpname.
BUFFER-COPY customer TO tmpName.
END.
END.
ELSE DO:
FOR EACH customer NO-LOCK WHERE Customer.NO = piCustomerNo:
CREATE tmpname.
BUFFER-COPY customer TO tmpName.
END.
END.
END PROCEDURE.
关于你所做的具体事件:
RUN searchCustomer(INPUT 0, OUTOUT TABLE tmpname).
或
RUN searchCustomer(INPUT iCustomer, OUTOUT TABLE tmpname).