Office中国论坛/Access中国论坛
标题: [求助]关于日期查询代码 [打印本页]
作者: hanbenben 时间: 2006-3-6 17:27
标题: [求助]关于日期查询代码
Private Sub 查询_Click()
If Not IsNull(Me.开始日期) Then
strWhere = strWhere & "([送检日期] >= #" & Format(Me.开始日期, "yyyy-mm-dd") & "#) AND "
End If
If Not IsNull(Me.结束日期) Then
strWhere = strWhere & "([送检日期] <= #" & Format(Me.结束日期, "yyyy-mm-dd") & "#) AND "
End If
Me.产品查询子窗体.Form.Filter = strWhere
Me.产品查询子窗体.Form.FilterOn = True
Set rs = Me.Recordset.Clone
rs.FindFirst "[供应商] = '" & Me![供应商列表] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End If
End Sub
但是“Me.产品查询子窗体.Form.Filter = strWhere
Me.产品查询子窗体.Form.FilterOn = True”
总是出错,请问是什么问题?
[此贴子已经被作者于2006-3-6 9:28:01编辑过]
作者: fan0217 时间: 2006-3-6 17:32
strWhere 的值不符合SQL的Where子句的要求。
作者: hanbenben 时间: 2006-3-6 18:09
可是我输入正确的日期格式,仍然会出错
作者: nagee 时间: 2006-3-6 18:35
If Not IsNull(Me.开始日期) Then
strWhere = strWhere & "([送检日期] >= # " & Me.开始日期 & "# ) AND "
End If
If Not IsNull(Me.结束日期) Then
strWhere = strWhere & "([送检日期] <= # " & Me.结束日期 & "#) AND "
End If
[此贴子已经被作者于2006-3-6 10:35:15编辑过]
作者: hanbenben 时间: 2006-3-6 19:27
Me.products query subform.Form.Filter = strWhere
Me.products query subform.Form.FilterOn = True
还是一样出错,说是语法错误
作者: eyewitnes 时间: 2006-3-7 04:06
debug.print strWhere 看看吧
作者: wangf 时间: 2007-1-23 16:02
1
作者: wangf 时间: 2007-1-23 20:49
1
作者: wangf 时间: 2007-1-23 21:00
我也有同样的问题怎样解决的呀!有人知道吗?
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) |
Powered by Discuz! X3.3 |