Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for better logic
Message
From
24/01/2000 20:28:37
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00321739
Message ID:
00321968
Views:
15
>I am looking for better logic to my input statement.
>I have 10 input boxes representing 10 diff fields which the user enters values into as many as he likes to narrow down his search.
>the more textboxes filled out, the more narrow his search becomes.
>Then I must set a filter using my screwy logic unless someone has a good idea for me.
>Thank you !

Timothy,

I did something like this once. Mine were check boxes. Since you said that you could SELECT into a cursor...

The trick is to construct the WHERE clause with an extra "AND" on the front, and then SUBSTR it off. That way you won't have to always be checking to see if you have a condition.
cMySelect = [SELECT * FROM MyTable ]
cMyWhere = ;
    IIF(!EMPTY(Field1), [ AND Field1 = ] + EnteredValue1, []) + ;    
    IIF(!EMPTY(Field2), [ AND Field2 = ] + EnteredValue2, []) + ;
    ....
    IIF(!EMPTY(FieldN), [ AND FieldN = ] + EnteredValueN, [])
cMyOrder = SomeOrder

cMySQLStatement = ;
    cMySelect + ;
    IIF(!EMPTY(cMyWhere), [WHERE ] + SUBSTR(cMyWhere, 6)) + ;
    cMyOrder
&cMySQLStatement
I hope this gives you the idea.
Previous
Reply
Map
View

Click here to load this message in the networking platform