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)
>* cWhere = "MyTable.MyField == '"+TRANSFORM(thisform.Text1.Value)+"'"
>* cWhere = "DTOS(MyTable.MyField) == '"+DTOS(thisform.Text1.Value)+"'"
> lAnd = .t.
> ENDIF
>
> IF .NOT. EMPTY(thisform.Text2.Value)
> cWhere = IIF(lAnd," AND ","") + "MyTable.MyField == "+TRANSFORM(thisform.Text2.Value)
> 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