我想用checkbox来实现动态的SQL查询条件选择
但是太费劲了!
比如我有4个条件可以复选~那么复选就有16种可能了~要判断16次??
有没有更好的方法或是程序让我参考下~谢谢了~如果没有更好的方法我就放弃了,只允许单选了!~~~

解决方案 »

  1.   

    其实不用判断16次那么多啊
    我在程序中是这么做的:
     If Chkjxname2.Value Then strcon1 = " and 记录者='" & Trim(Cmbjxname2.Text) & "'" Else strcon1 = ""
     If Chkjxitem2.Value Then strcon2 = " and 项目='" & Trim(Cmbjxitem2.Text) & "'" Else strcon2 = ""
     If Chkjxdriver2.Value Then strcon3 = " and 设备名='" & Trim(Cmbjxdriver2.Text) & "'" Else strcon3 = ""
     If Chkjxstate2.Value Then strcon4 = " and 状态='" & Trim(Cmbjxstate2.Text) & "'" Else strcon4 = ""
     strcondition = strcon1 & strcon2 & strcon3 & strcon4
    不过这样做有个前提,就是你必须有一个初始条件,比如说时间范围