Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching using SQL
Message
From
23/07/2003 08:53:24
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00812676
Message ID:
00812735
Views:
14
More or less, but the case statements aren't really necessary:
lcDesign = 'modacad.key3' + ThisForm.combo1.Value + 'ThisForm.Text1.Value'
It gives you the other comparisons too (<, >, !=, ==) without creating an even bigger case clause.

Otherwise you're doing pretty much what I do.

Alan

>Good Morning,
>
>I have a form with 5 Text Boxes and 5 Combos. What I am trying to do is to search a table by any combination of those 5 fields. In each of the combo's I have 2 values which are = and $ which means we can produce different types of searches.
>
>If I was searching with the first field then my syntax would be something like:
>
>
>Local lcdesign
>
>DO CASE
>	CASE thisform.combo1.displayvalue='='
>           lcdesign="modacad.key3=thisform.text1.value"
>        CASE thisform.combo1.displayvalue='$'
>           lcdesign="modacad.key3$thisform.text1.value"              	
>ENDCASE
>
>WITH main.lstSource
> .RowSourcetype = 3
> .Rowsource = 'SELECT mainkey FROM ("U:\Data\modacad.dbf")'+;
>              'WHERE &lcdesign order BY mainkey into cursor result'
> .ColumnCount = 1
>ENDWITH
>
>
>That is for the first field named Design Number. Now I want to include another field:
>
>
>LOCAL lcdesign
>
>DO CASE
>	CASE thisform.combo1.displayvalue='='
>           lcdesign="modacad.key3=thisform.text1.value"
>        CASE thisform.combo1.displayvalue='$'
>           lcdesign="modacad.key3$thisform.text1.value"              	
>ENDCASE
>
>IF NOT EMPTY( ThisForm.text2.value )
>  lcDesign = lcDesign + ' AND modacad.key4 = ' + ThisForm.Text2.Value
>ENDIF
>
>SELECT * ;
>FROM ("U:\Data\modacad.dbf") ;
>WHERE &lcdesign ;
>order BY mainkey ;
>INTO CURSOR crssearch
>
>
>I have another 3 fields now to add into my search. Basically what I am after is that I have 5 Text fields (Text1....Text5) each having a combo (Combo1....Combo5).
>
>I would like to be able to search by any combination of fields? Am I going down the right lines?
>
>Many Thanks
Previous
Reply
Map
View

Click here to load this message in the networking platform