dim tmp_user as string
dim tmp_date as string
dim strsql as string
dim rs as new adodb.recordset
if trim(txtuser.text)="" then
tmp_user=""
else
tmp_user=" and 用户='"& trim(txtuser.text) &"'"
end if
if trim(txtdate.text)="" then
tmp_date=""
else
tmp_date=" and 日期=# " & format(txtdate.text,"YYYY-MM-DD") & " #"
end if
strsql=" select * from tablename where 1=1 " & tmp_user & tmp_date
if rs.state=adstateopen then rs.close
rs.open strsql,conn,adopenkeyset,adlockreadonly