dim where_tem as string
dim where_pre as string
dim where_flow as string
dim where_media as string
dim strsql as string
'温度条件
if trim(temtext2.text)="" and trim(temtext3.text)="" then
where_tem=""
end if
if trim(temtext2.text)<>"" and trim(temtext3.text)="" then
where_tem=" and 温度字段>="& temtext2.text &""
end if
if trim(temtext2.text)="" and trim(temtext3.text)<>"" then
where_tem=" and 温度字段<="& temtext3.text &""
end if
if trim(temtext2.text)<>"" and trim(temtext3.text)<>"" then
where_tem=" and 温度字段 between "& temtext2.text &" and "& temtext3.text &""
end if
'压力条件
if trim(pretext2.text)="" and trim(pretext3.text)="" then
where_pre=""
end if
if trim(pretext2.text)<>"" and trim(pretext3.text)="" then
where_pre=" and 压力字段>="& pretext2.text &""
end if
if trim(pretext2.text)="" and trim(pretext3.text)<>"" then
where_pre=" and 压力字段<="& pretext3.text &""
end if
if trim(pretext2.text)<>"" and trim(pretext3.text)<>"" then
where_pre=" and 压力字段 between "& pretext2.text &" and "& pretext3.text &""
end if
'流量条件
if trim(flowtext2.text)="" and trim(flowtext3.text)="" then
where_flow=""
end if
if trim(flowtext2.text)<>"" and trim(flowtext3.text)="" then
where_flow=" and 流量字段>="& flowtext2.text &""
end if
if trim(flowtext2.text)="" and trim(flowtext3.text)<>"" then
where_flow=" and 流量字段<="& flowtext3.text &""
end if
if trim(flowtext2.text)<>"" and trim(flowtext3.text)<>"" then
where_flow=" and 流量字段 between "& flowtext2.text &" and "& flowtext3.text &""
end if
'介质条件
if trim(datacombo.text)="" then
where_media=""
else
where_media=" and 介质字段='"& trim(datacombo.text) &"'"
end if
'构造SQL查询语句
strsql=" select * from tablename where 1=1 " & where_tem & where_pre & where_flow & where_media