Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple Field Searching Tables
Message
From
28/07/2003 08:03:08
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00814015
Message ID:
00814027
Views:
11
You need to create a macro. In other words, assuming you have a search entry form with the three text boxes, something like:
lcWhere = ""
If !empty(thisform.text1.Value)
   lcWhere = ' WHERE thisform.text1.value=modacad.key1'
Endif
If !empty(thisform.text2.Value)
   If !empty(lcWhere)
      lcWhere = lcWhere + " and "
   Endif
   lcWhere = lcWhere +  'WHERE thisform.text2.value=modacad.key2'
Endif
If !Empty(thisform.text3.value)
   If !Empty(lcWhere)
      lcWhere = lcWhere + " and "
   Endif
   lcWhere = lcWhere + 'WHERE thisform.text3.value=modacad.key3'
endif

lcSelect = 'SELECT mainkey FROM ("U:\Data\modacad.dbf")' + lcWhere + ;
              ' order BY mainkey into cursor result'

&lcSelect
>Good Morning,
>
>I have a form with 3 fields i.e. Text1, Text2 and Text3
>
>Text1 relates to modacad.key1 field
>Text2 relates to modacad.key2 field
>Text3 relates to modacad.key3 field
>
>With the following SQL statement I would like to search a table named modacad.
>
>The problem is this is for 1 field named Text1. The user may not search on the Text1 field. They may decide to search on Text2 field. I was wondering if anybody coule help on how to search a table by any COMBINATION of fields. The user could search using Text1 and Text3 fields or just Text2 fields.
>
>
>WITH main.lstSource
> .RowSourcetype = 3
> .Rowsource = 'SELECT mainkey FROM ("U:\Data\modacad.dbf")'+;
>              'WHERE thisform.text1.value=modacad.key1 order BY mainkey'+;
>              'into cursor result'
> .ColumnCount = 1
>ENDWITH
>
>
>
>Many Thanks in Advance
Previous
Reply
Map
View

Click here to load this message in the networking platform