You don't have to build query in VFP, you can run it directly
select * from customers ;
where project = ALLTRIM(thisform.text1.value) ;
AND contract = ALLTRIM(thisform.text2.value) ;
into cursor lcSource
>i want to run a select query, i have two text boxes text1 and text2,
>
>If any of the text fields are filled then the values need to be passed to the select query text1 for project, text2 for contract.
>
>Can you please modify the following to do the above function, the following i use mostly in VB. I am not good in foxpro.
>
>***************
>if thisform.text1.value <> "" then
> swhere = "where project = thisform.text1.value ";
>endif
>
>if thisform.text2.value <> "" then
> if swhere <> "" then
> swhere = swhere & "contract=thisform.text2.value ";
> else
> swhere = "contract=thisform.text2.value ";
> endif
>endif
>
>sorder = "order by projid"
>
>swherestatement = swhere + sorder
>
>lSQL = [select * from customers swherestatement into cursor lcSource]
>
>*********************
>
>Thank you very much in advance.
--sb--