Problems with Recordset Filter

白昼怎懂夜的黑 提交于 2019-12-01 14:27:48

ADO Recordset Object Filter Property:

There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this:

(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'

Instead, you would construct this filter as:

(LastName = 'Smith' AND FirstName = 'John') OR

(LastName = 'Jones' AND FirstName = 'John')

So you would have to construct your filter like this:

rs.Filter = "( Status = 1 AND End_Date = null ) OR ( Status = 1 AND End_Date > #" & Date() & "# )"

I know that you are working with legacy code and probably other things are working, but how do you open the recordset in this specific page? Are you using some constant defined in adovbs.inc?

For example:

rs.Open "SELECT * FROM table1", db, adOpenStatic, adLockPessimistic

What happens when you try this...

Dim strToday
strToday = Now()
rs.Filter = "Status=1 AND (End_Date = null OR End_Date > """ & strToday & """)" 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!