VB access 用控件adodc 查询

来源:百度知道 编辑:UC知道 时间:2024/06/26 01:18:21
自己写了个程序,有多条件的查询,查询的条件很多。随意组合查询。做好可以发给我邮箱,或者留下联系方式 给程序看下!

1楼说得很好

就是组合SQL语句
比如你有表tb,要用checkbox组合字段f1,f2,f3作查询条件:

dim sql as string

sql="select * from tb where 1=1 "

if check1 then sql=sql & " and f1='"& trim(text1) &"'" 'f1文本类型
if check2 then sql=sql & " and f2="& val(text1) 'f2数值类型
if check3 then sql=sql & " and f3=#"& trim(text1) &"#" 'access的日期类型

'debug.print sql 可以这样在立即窗口输出sql语句,放入查询分析器中测试

组合的时候一定要注意字符之间的空格...