小刀人
-No business too small, no problem too big.
<2007年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678
公告
  • Learn,Think,and Imagine...

    正在看的书:

    点击发送消息给我

留言簿(6)

随笔分类

随笔档案

文章档案

相册

CSDN

VC知识库

开发站点

技术blog

搜索

最新评论

阅读排行榜

评论排行榜

 
VC知识库BLOG   首页  新随笔  联系  聚合  登录 
  随笔-23 文章-0 评论-61 Trackbacks-0
为给单位的一个小软件(Access+VBA)加个字段筛选器,要求筛选条件是后台操作,而非显式筛选。开始用常用的几招都不能奏效。查了书,也没有找到方法。查msdn在500个主题中找到这一条:ACC2000: Setting the Filter Property of a Form Does Not Apply the Filter。看了半天,忽然想到孔乙己,茴香豆的“茴”有n种写法......
原文如下:
.......

Symptoms

Setting the Filter property of a form does not apply the filter.


Cause

The Filter property holds the filter that is applied when the filtering process is started, but does not start the filtering process.

Resolution

You must set the FilterOn property of the form to True to apply the filter. If you want the filter to be applied when the form opens, you can set the FilterOn property to True on the Open event of the form by using a macro or Visual Basic code, or you can apply the filter manually.

Method 1: Using a Macro

To apply a filter when the form is opened, create the following macro and set the form's OnOpen property to the following macro:
Action: SetValue
Item: FilterOn
Expression: True

Method 2: Using Visual Basic Code

To apply a filter when the form is opened, set the form's OnOpen property to the following event procedure:
Private Sub Form_Open(Cancel As Integer)
   Me.FilterOn = True
End Sub 

Method 3: Applying a Filter Manually

To apply a filter after the form is opened:
  • Click Apply Filter on the Form View toolbar.

    -or-
  • Click Apply Filter/Sort on the Records menu.

More Information

Steps to Reproduce Behavior

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

  1. Open the sample database Northwind.mdb.
  2. Open the Orders form.

  3. Press CTRL+G to open the Immediate window. In the Immediate window, type the following line, and then press ENTER:
    Forms!Orders.Filter = "OrderID = 10926"
    Note that nothing is returned.
  4. In the Immediate Window, type the following line, and then press ENTER:
    Forms!Orders.FilterOn = True
    Note that the filter is now applied.

我发现More Information的步骤可以,Filter的=右边的格式怎么写呢,试了好几种写法,终于成功:

Me.[××××× 子窗体].Form.Filter = "(status<>'无') And (status<>'不合格') And ( rejectornot<>True)"

其中rejectornot字段是复选框。

posted on 2005-02-28 21:34 小刀人 阅读(3417) 评论(1)  编辑 收藏
Comments
  • # re: Filter问题
    sun
    Posted @ 2007-11-02 18:38
    非常非常感谢!找了半天也没有一个如此言简却明确正确的文章
    Me.[××××× 子窗体].Form.Filter = "(status<>'无') And (status<>'不合格') And ( rejectornot<>True)"
标题  
姓名  
主页
验证码 *
内容   
  登录  使用高级评论  Top
[使用Ctrl+Enter键可以直接提交]