我设置了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 & "#" & ""也是错误的
请帮帮忙.
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 & "#" & ""也是错误的
请帮帮忙.
解决方案 »
- cad vba 二次开发 填充圆问题
- 类QQ的程序怎么写啊
- '在控件工程的窗体上调用控件窗体内的函数,能否实现?
- 初学者问题很简单
- 请教Ado
- 救救小女子!!要不然下个星期小女子就要被老师掐死了!!!17:00结帖!!
- 奇怪了!!!怎么我的单击事件要点两次按钮才可以啊!
- 请问如何将图片文件读出,而且还可以写到RTF文件或者数据库里面?我需要源码。
- vb可以实现像按键那样对脚本进行暂停、继续、停止吗?具体怎么做?
- 会vb的同志们都来看看!留下您的OICQ、ICQ、E-MAIL、HomePage、Tel!!!
- 请教,VB MScomm和单片机通讯,如何从接收帧中把数据分离显示在TEXT控件上.谢谢
- 文件操作的问题
str1=" 入司时间 between #" & DTPicker1.Value & "# and #" & DTPicker2.Value & "# " str2=" 出生年月 between #" & DTPicker3.Value & "# and #" & DTPicker4.Value & "#"
StrSQL = StrSQL & str2 & str1如果不行可能和DTpicker1 Value的类型有关,可以定义4个变量代替
dim d1 as date
dim d2 as date
dim d3 as date
dim d4 as date d1=DTPicker1.value
...
...
str1=" 入司时间 between #" & d1 & "# and #" & d2 & "# "
str2=" 出生年月 between #" & d3 & "# and #" & d4 & "#"
...
Dim StrSQL As String
StrSQL = "select * from 员工档案 where "
if Check1 = 1 AND Check2=1 Then
StrSQL = StrSQL & " 入司时间 between #" & DTPicker1.Value & "# and #" & DTPicker2.Value & "#" & "" & " 出生年月 between #" & DTPicker3.Value & "# and #" & DTPicker4.Value & "#" & ""
end if
If rs3.State = adStateClosed Then
rs3.Open StrSQL, DBCON, adOpenKeyset, adLockOptimistic, adCmdText
End If
Set VSFlexGrid2.DataSource = rs3.DataSource
Label14.Caption = rs3.RecordCount
VSFlexGrid2.Refresh
rs3.Close
这是我的代码,错误原因是"where子句语法错误",以上的我也试过了,还是不行,不知道怎么改了,脑袋大了
或者'" & DTPicker.Value & "'试试。
str2= " 出生年月 between #" & DTPicker3.Value & "# and #" & DTPicker4.Value & "#" & ""
这两个时间条件难道就不能同时满足吗?大家帮帮忙啊
str2= " 出生年月 between #" & DTPicker3.Value & "# and #" & DTPicker4.Value & "#" & ""
这两个时间条件难道就不能同时满足吗?大家帮帮忙啊
*****************************************************************************
菜鸟一只
建议在数据库中输入一个同时符合两个条件的记录试试str1= " 入司时间 between #" & DTPicker1.Value & "# and #" & DTPicker2.Value & "#" & ""
str2= " 出生年月 between #" & DTPicker3.Value & "# and #" & DTPicker4.Value & "#" & ""StrSQL = "select * from 员工档案 where " + str1 + " and " + str2
str2= " 出生年月 between #" & DTPicker3.Value & "# and #" & DTPicker4.Value & "#" & ""
str3="工号= '" & Trim(Text1(0).Text) & "'"
str4="姓名= '" & Trim(Text1(1).Text) & "'"
请教一下stlyl(stlyl(维生素B)) ,这个怎么连??我按你的方法,时间的问题是解决了,不过这四个又有语法错误了,请指教,谢谢