请教组合条件查询表单设计问题
如图,本人制作了一个组合条件查询表单,设计思路是:
用户在“条件选择”列表框中选定字段后,其值显示在text1文本框中,再选择“关系运算符”,其值显示在text2文本框中,在text3中输入查询值,点击“添加条件”按纽,条件表达式显示在text4文本框中。用户可以重复添加多个条件,text4的值随添加的条件动态改变。最后依据text4值的组合条件表达式筛选数据。
在表单的load事件中添加了如下代码:
DIMENSION zdtj(6),gxysf(6),cxz(6),ljysf(6)
PUBLIC cxtj,i
cxtj=''
i=1
list1的InteractiveChange事件代码:
DO case
CASE thisform.list1.Value='企业代码'
thisform.text1.Value='qyjbxxb.jgdm'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='企业名称'
thisform.text1.Value='qyjbxxb.jgmc'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='企业地址'
thisform.text1.Value='qyjbxxb.jgdz'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='行政区划'
thisform.text1.Value='qyjbxxb.xzqh'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='邮政编码'
thisform.text1.Value='qyjbxxb.yzbm'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='法人代表'
thisform.text1.Value='qyjbxxb.fddbr'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='经济行业'
thisform.text1.Value='qyjbxxb.jjhy'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='经济类型'
thisform.text1.Value='qyjbxxb.jjlx'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='企业类型'
thisform.text1.Value='qyjbxxb.jglx'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='职工人数'
thisform.text1.Value='qyjbxxb.zgrs'
thisform.Optiongroup1.option7.enabled= .F.
thisform.Optiongroup1.option8.enabled= .F.
thisform.Optiongroup1.option9.enabled= .F.
CASE thisform.list1.Value='年产值'
thisform.text1.Value='qyjbxxb.ncz'
thisform.Optiongroup1.option7.enabled= .F.
thisform.Optiongroup1.option8.enabled= .F.
thisform.Optiongroup1.option9.enabled= .F.
CASE thisform.list1.Value='登记日期'
thisform.text1.Value='DTOC(qyjbxxb.djrq,1)'
thisform.Optiongroup1.option7.enabled= .F.
thisform.Optiongroup1.option8.enabled= .F.
thisform.Optiongroup1.option9.enabled= .F.
CASE thisform.list1.Value='认证类型'
thisform.text1.Value='qyjbxxb.rzlx'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='产品名称'
thisform.text1.Value='qyzycpk.zycp'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='产品类别'
thisform.text1.Value='qyzycpk.cplb'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='执行标准等级'
thisform.text1.Value='qyzycpk.cpbzdj'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='是否采标'
thisform.text1.Value='qyzycpk.cbbz'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='获奖名称'
thisform.text1.Value='qyzycpk.hjmc'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='许可类型'
thisform.text1.Value='qyzycpk.xklx'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
CASE thisform.list1.Value='许可证号'
thisform.text1.Value='qyzycpk.xkzh'
thisform.Optiongroup1.option2.enabled= .F.
thisform.Optiongroup1.option3.enabled= .F.
thisform.Optiongroup1.option4.enabled= .F.
thisform.Optiongroup1.option5.enabled= .F.
ENDCASE
zdtj(i)=alltrim(thisform.text1.value)
Optiongroup1的InteractiveChange代码:
if thisform.Optiongroup1.Value=10
thisform.text2.Value='is'
thisform.text3.value='null'
ELSE
DO case
CASE thisform.Optiongroup1.Value=1
thisform.text2.Value='='
CASE thisform.Optiongroup1.Value=2
thisform.text2.Value='>'
CASE thisform.Optiongroup1.Value=3
thisform.text2.Value='>='
CASE thisform.Optiongroup1.Value=4
thisform.text2.Value='<'
CASE thisform.Optiongroup1.Value=5
thisform.text2.Value='<='
CASE thisform.Optiongroup1.Value=6
thisform.text2.Value='<>'
CASE (thisform.Optiongroup1.Value=7).or.(thisform.Optiongroup1.Value=8).or.(thisform.Optiongroup1.Value=9)
thisform.text2.Value='like'
ENDCASE
thisform.text3.SetFocus
ENDIF
gxysf(i)=ALLTRIM(thisform.text2.Value)
Combo1的InteractiveChange代码:
if
DO case
CASE
ljysf(i)='.and.'
CASE
ljysf(i)='.or.'
ENDCASE
thisform.text1.Value=''
thisform.text2.Value=''
thisform.text3.Value=''
thisform.list1.SetFocus
thisform.Optiongroup1.value=0
thisform.Optiongroup1.option2.enabled= .T.
thisform.Optiongroup1.option3.enabled= .T.
thisform.Optiongroup1.option4.enabled= .T.
thisform.Optiongroup1.option5.enabled= .T.
thisform.Optiongroup1.option7.enabled= .T.
thisform.Optiongroup1.option8.enabled= .T.
thisform.Optiongroup1.option9.enabled= .T.
ENDIF
在“添加条件”按纽的click事件中,添加了如下代码:
IF EMPTY(zdtj).or.empty(gxysf).or.empty(cxz)
MESSAGEBOX('您还没有设置条件!')
thisform.list1.SetFocus
ENDIF
IF (thisform.Optiongroup1.Value=7).or.(thisform.Optiongroup1.Value=8).or.(thisform.Optiongroup1.Value=9)
DO case
case thisform.Optiongroup1.Value=7
cxtj=cxtj+zdtj(i)+' '+gxysf(i)+' '+'"%'+cxz(i)+'%"'
CASE thisform.Optiongroup1.Value=8
cxtj=cxtj+zdtj(i)+' '+gxysf(i)+' '+'"%'+cxz(i)+'"'
CASE thisform.Optiongroup1.Value=9
cxtj=cxtj+zdtj(i)+' '+gxysf(i)+' '+'"'+cxz(i)+'%"'
ENDCASE
ELSE
IF thisform.Optiongroup1.Value=10
cxtj=cxtj+zdtj(i)+' '+gxysf(i)+' '+'"'+cxz(i)+'"'
ELSE
cxtj=cxtj+zdtj(i)+gxysf(i)+cxz(i)
ENDIF
ENDIF
IF
cxtj=cxtj+ljysf(i)
ENDIF
thisform.text4.value=cxtj
运行表单,选择字段条件后,显示:
在“添加条件”按纽的click事件代码最后加一行:
i=i+1
再运行,选择字段条件后则提示:
请问:我的问题出在哪里?怎样解决?
谢谢!
[ 本帖最后由 陶然愚者 于 2013-1-22 13:18 编辑 ]