可以动态构造SQL语句,比如窗体上代码:dim sql as string dim s1 as string,s2 as stringsql="select * from tb where 1=1 " if 条件1 then s1=" and f1='"& text1.text &"'" end if if 条件2 then s2=" and f2="& val(text1.text) end ifsql=sql & s1 & s2 ...... rs.open sql,cn,1,3 ...... set rpt.datasource=rs rpt.show'rpt是你的报表
dim s1 as string,s2 as stringsql="select * from tb where 1=1 "
if 条件1 then
s1=" and f1='"& text1.text &"'"
end if
if 条件2 then
s2=" and f2="& val(text1.text)
end ifsql=sql & s1 & s2
......
rs.open sql,cn,1,3
......
set rpt.datasource=rs
rpt.show'rpt是你的报表