Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with search form...
Message
 
 
To
04/02/2001 21:10:58
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00472369
Message ID:
00472395
Views:
32
>I have want to create a search form to search for partial matches on either of three fields, and return the results into a grid...
>
>The fields I want to search on are:
>
>PO_NUM c(15)
>DESCRIP memo
>CUST_NUM c(6)

And the problem is what? Create a SQL command based on the user's input to a search form.
local lcPO_Num, lcDescrip, lcCust_Num, lcSQL, lcAnd
lcPO_Num   = alltrim(ThisForm.txtPO_Num.Value)
lcDescrip  = alltrim(ThisForm.txtDescrip.Value)
lcCust_Num = alltrim(ThisForm.txtCust_Num.Value)

if empty(lcPO_Num + lcDescrip + lcCust_Num)
   ** invalid
   return .f.
endif

lcSQL = "select field_list_here from mytable where "
lcAnd = ""
if not empty(lcPO_Num)
   lcSQL = lcSQL + "PO_Num like '%" + lcPO_Num + "%' "
   lcAnd = "AND "
endif
if not empty(lcDescrip)
   lcSQL = lcSQL + lcAnd + "Descrip like '%" + lcDescrip + "%' "
   lcAnd = "AND "
endif
if not empty(lcCust_Num)
   lcSQL = lcSQL + "Cust_Num like '%" + lcCust_Num + "%' "
endif
lcSQL = lcSQL + "order by PO_Num into cursor crsResults"
if used("crsResults")
   use in crsResults
endif
&lcSQL
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform