Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select query with where condition using IF
Message
 
 
To
21/05/2004 14:44:51
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00906100
Message ID:
00906106
Views:
20
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--
Previous
Reply
Map
View

Click here to load this message in the networking platform