毕业设计问题
查询条件:
一:温度 上限(temtext2.txt)下限(temtext3.txt)
二:流量 上限(flowtext2.txt)下限(flowtext3.txt)
三:压力 上限(pretext2.txt)下限(pretext.txt)
四:介质(meddatacombo)
我想使用check来实现单一查询或几个条件的并列查询,数据库使用access
例如:将temtext2.txt>数据库中[温度上限字段]和数据库中[温度下限字段]<temtext3.txt的所有零件都列出来
流量 压力 同温度
我是机械专业的,以前没学过VB,大家帮帮忙,谢谢

解决方案 »

  1.   

    "Select * From 表名 where 温度 between " & temtext2.text & " and " & temtext3.text
      

  2.   

    你这个问题有点大了,不是几句话几行代码可以回答的。
    建议你先把问题的流程思考清楚。
    解决的技巧无非是把CheckBox的值与查询条件进行关联。
      

  3.   

    DIM sSQL As String
    sSQL = "select * from table where"
    If text1<>"" sSQL= sSQL & " cond1>" & val(text1.text) & " and cond1<" & val(text2.text)
    if text2<>"" sSQL = sSQL & " cond2>" & val(text3.text) & " and cond2<" & val(text4.text)
    ......'判断结束
    if right(sSQL,3)= "and" then sSQL=left(sSQL,len(sSQL)-3)
    if right(sSQL,5) = "where"  then .... 去掉where 
      

  4.   

    就是构造SQL语句,类似:dim sql as stringsql="select * from tb where 1=1 "
    if check1.value=1 then sql=sql & " and fld1 ='"& temtext2.text &"' "
    if check2.value=1 then sql=sql & " and fld2 ='"& temtext3.text &"' "
    '................
    cn.execute sql