Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multiple Field Searching Tables
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00814015
Message ID:
00814034
Vues:
12
Hi Neil,

You didn't specify logical joind between conditions. I assumed that it's 'AND'. This code can be easily modified to FOR loop.
lcWhereCond = ""
IF NOT EMPTY(thisform.text1.value)
	lcWhereCond = IIF( NOT EMPTY(lcWhereCond), " AND ", "") + 
		"modacad.key1 = thisform.text1.value"
ENDIF
IF NOT EMPTY(thisform.text2.value)
	lcWhereCond = IIF( NOT EMPTY(lcWhereCond), " AND ", "") + 
		"modacad.key2 = thisform.text2.value"
ENDIF
IF NOT EMPTY(thisform.text3.value)
	lcWhereCond = IIF( NOT EMPTY(lcWhereCond), " AND ", "") + 
		"modacad.key3 = thisform.text3.value"
ENDIF
BTW, it's bad idea to use hardcoded pathes in your application. It'll be nightmare if you ever have to move data around. You should also open table explicitly with USE command or using DE of the form. After that you can reference the tables by alias.


>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
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform