Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Building a complex query
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows 2000 SP4
Network:
Windows 2000 Pro
Database:
Visual FoxPro
Divers
Thread ID:
00980679
Message ID:
00980711
Vues:
67
Borislav

I have tried that with the following code

In my test councoun and clicoun were non blank - agentcoun was blank

It selected all records that matched criterion 2 - it should have selected al those where criterion 1 AND 2 had been met

IF .NOT. EMPTY(concoun)
cWhere = "globalnew.country == '"+TRANSFORM(concoun)+"'" && for Char Fields
lAnd = .t.
ENDIF

IF .NOT. EMPTY(clicoun)
cWhere = "globalnew.acclient == '"+TRANSFORM(clicoun)+"'" && for Char Fields
lAnd = .t.
ENDIF

IF .NOT. EMPTY(agentcoun)
cWhere = "globalnew.aname == '"+TRANSFORM(agentcoun)+"'" && for Char Fields
lAnd = .t.
ENDIF





>Ok
>Then something like that:
>cWhere = ""
>lAnd = .f.
>
>  IF .NOT. EMPTY(thisform.Text1.Value)
>     cWhere  = "MyTable.MyField == "+TRANSFORM(thisform.Text1.Value) && for Numeric Fields
>*     cWhere = "MyTable.MyField == '"+TRANSFORM(thisform.Text1.Value)+"'" && for Char Fields
>*     cWhere = "DTOS(MyTable.MyField) == '"+DTOS(thisform.Text1.Value)+"'" && for Date Fields
>      lAnd   = .t.
>  ENDIF
>
>  IF .NOT. EMPTY(thisform.Text2.Value)
>     cWhere = IIF(lAnd," AND ","")  + "MyTable.MyField == "+TRANSFORM(thisform.Text2.Value) && for Numeric Fields
>      lAnd   = .t.
>  ENDIF
>
> ....
>cWhere = IIF(EMPTY(cWhere),".t.", cWhere)
>
>SELECT .... FROM .... WHERE &cWhere INTO ...
>
Specialist in Advertising, Marketing, especially Direct Marketing

I run courses in Business Management and Marketing
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform