当我使用姓名的起始字母在名称填写中搜索时,它应显示以该字母开头的所有名称。
提示:它应该使用open query`
DO:
IF (input customer.cust-num <> 0) and (input customer.name = "") then do:
find first customer where ( customer.cust-num = input cust-num) no-error.
OPEN QUERY custqry FOR EACH customer.
display customer.cust-num customer.name customer.balance customer.discount customer.credit-limit customer.phone customer.contact with browse br1 . /*to display in browser*/
assign
ocustnum = customer.cust-num
oName = customer.Name
obalance = customer.balance
odiscount = customer.discount
ocredit-limit = customer.credit-limit
ophone = customer.phone
ocontact = customer.contact .
display ocustnum oName obalance odiscount ocredit-limit ophone ocontact with frame default-frame . /*to display in fillin*/
end.
ELSE IF (input customer.cust-num = 0) and (input customer.name <> "") then do:
find first customer where customer.name begins input name no-error .
OPEN QUERY q FOR EACH customer BY name.
display customer.cust-num customer.name customer.balance customer.discount customer.credit-limit customer.phone customer.contact with browse br1. /*to display in browser*/
assign
ocustnum = customer.cust-num
oName = customer.Name
obalance = customer.balance
odiscount = customer.discount
ocredit-limit = customer.credit-limit
ophone = customer.phone
ocontact = customer.contact .
display ocustnum oName obalance odiscount ocredit-limit ophone ocontact with frame default-frame . /*to display in fillin*/
end.
ELSE IF (input customer.cust-num <> 0) and (input customer.name <> "") then do:
find first customer where ( customer.cust-num = input cust-num) and (customer.name begins input name) no-lock no-error .
OPEN QUERY cust-query FOR EACH customer BY name.
display customer.cust-num customer.name customer.balance customer.discount customer.credit-limit customer.phone customer.contact with browse br1. /*to display in browser*/
assign
ocustnum = customer.cust-num
oName = customer.Name
obalance = customer.balance
odiscount = customer.discount
ocredit-limit = customer.credit-limit
ophone = customer.phone
ocontact = customer.contact .
display ocustnum oName obalance odiscount ocredit-limit ophone ocontact with frame default-frame . /*to display in fillin*/
end.
END.
` 我为搜索按钮编写的上述代码。enter image description here
答案 0 :(得分:0)
使用BEGINS匹配字符串的开头并使用BY控制排序顺序:
OPEN QUERY q FOR EACH customer
WHERE customer.name BEGINS (INPUT customer.name) BY name.