关于DTPicker连接一个日期的问题,请帮忙
我设置了4个DTPicker,分别为DTPicker1,DTPicker2,DTPicker3,DTPicker4.
StrSQL = "select * from 员工档案 where "
str1= " 入司时间 between # " & DTPicker1.Value & "# and # " & DTPicker2.Value & "# " & " "
str2= " 出生年月 between # " & DTPicker3.Value & "# and # " & DTPicker4.Value & "# " & " "
怎样才能同时满足这两个条件实施查询??
我是这样写的StrSQL = StrSQL & str2 & str1,系统提示语法错误,
要是这样的话
StrSQL =& " 入司时间 between # " & DTPicker1.Value & "# and # " & DTPicker2.Value & "# " & " " and & " 出生年月 between # " & DTPicker3.Value & "# and # " & DTPicker4.Value & "# " & " "也是错误的
请帮帮忙.
[解决办法]
如果str1和str2都没错的话,那么用“and” 连接起来应该是没错的
建议在数据库中输入一个同时符合两个条件的记录试试
str1= " 入司时间 between # " & DTPicker1.Value & "# and # " & DTPicker2.Value & "# " & " "
str2= " 出生年月 between # " & DTPicker3.Value & "# and # " & DTPicker4.Value & "# " & " "
StrSQL = "select * from 员工档案 where " + str1 + " and " + str2