弄个通用代码给你吧:五个项目,任意一个有内容则要求该项目完全匹配;为空则忽略该项目。
ss='.T.'
ss=ss+iif(empty(thisform.text1.value),'',' and 组织代码==allt(thisform.text1.value)')
ss=ss+iif(empty(thisform.text2.value),'',' and 单位名称==allt(thisform.text2.value)')
ss=ss+iif(empty(thisform.text3.value),'',' and 街镇==allt(thisform.text3.value)')
ss=ss+iif(empty(thisform.combo1.displayvalue),'',' and 年=thisform.combo1.displayvalue')
ss=ss+iif(empty(thisform.combo2.displayvalue),'',' and 年=thisform.combo2.displayvalue')
sele sj
set filt to &ss
go top
thisform.grid1.refresh
第五个条件没改一下,应该是“月”
ss='.T.'
ss=ss+iif(empty(thisform.text1.value),'',' and 组织代码==allt(thisform.text1.value)')
ss=ss+iif(empty(thisform.text2.value),'',' and 单位名称==allt(thisform.text2.value)')
ss=ss+iif(empty(thisform.text3.value),'',' and 街镇==allt(thisform.text3.value)')
ss=ss+iif(empty(thisform.combo1.displayvalue),'',' and 年=thisform.combo1.displayvalue')
ss=ss+iif(empty(thisform.combo2.displayvalue),'',' and 月=thisform.combo2.displayvalue')
sele sj
set filt to &ss
go top
thisform.grid1.refresh