字段:收入金额:money 对应控件:text1,text2,check2
收入日期:date 对应控件:combo1,combo2,check1
账户列别:type 对应控件:combo3,check3
收入来源:income 对应控件:combo4,check4
备注信息:info 对应控件:text3,check5
对应不是绑定,是为了说明我的代码。
private sub command_click()
dim constr as string
constr= "select * from 表 where "
if check1.value =1 then
constr = constr & "date > '" & combo1.text & "' and date < '" & combo2.text & "'"
end if
if check2.value =1 then
if right(trim(constr),5)<> "where" then constr = constr & "and "
constr = constr & "money > '" & right(text1.text ,len(text1.text)-1) & "' and mondy < '" & right(text2.text ,len(text2.text)-1) & "'"
end if
以下的写法都差不多
到最后一个check写完
就rec.open constr ,con
因为太麻烦,就没调试。可能有错误。
strCond="1=1"
if check1.value=1 then
strCond=strCond & " and 收入日期>='" & date1 & "' and 收入日期<='" & date2 & "' "
end if
if check2.value=1 then
strCond=strCond & " and 收入金额>='" & amt1 & "' and 收入金额<='" & amt2 & "' "
end if
.....
if strCond<>"1=1" then
sql="select * from tablename where " & strCond
end if
加1000分
吧
提示:多个check--->数组存
循环数组--条件判断(是否被选)---查询