过滤器无法使用“全选”复选框控件 [英] Filter not working with "Select All" checkbox control

查看:85
本文介绍了过滤器无法使用“全选”复选框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Access 2007中有一个名为Leadership Contact List的连续表单。它具有每个记录的复选框控件(绑定到基础表中的字段),用于通过电子邮件发送或为选定的联系人创建邮件标签。在表单标题中,有一个?Select All?复选框控件(当然)选择所有复选框。表单还在标题中有一个组合框,根据?代理类型过滤记录。


我想要的是创建标签或仅通过电子邮件发送过滤集中的选定联系人,并可选择使用选择一次选择所有联系人所有的"控制。


?选择全部?效果很好,直到表格被过滤。背后的代码?选择全部?继续将所有复选框设置为true,即使它们没有在表单中显示。那么当?电子邮件选择联系人?或?为所选联系人创建邮件标签?单击按钮,结果根本不会被过滤。


我试图在On Click事件的SQL语句中的Where子句中添加其他条件以考虑过滤器,但是我得到错误?参数太少。预计1? (错误#3061)。我不知道是不是因为我的语法有问题,或者因为我试图做一些我能做的事情?


这里的代码是有效的:

I have a continuous form in Access 2007 called ?Leadership Contact List.? It has a checkbox control for each record (bound to a field in the underlying table) that is used to email or create mailing labels for the selected contacts. In the form header, there is a ?Select All? checkbox control which (of course) selects all the checkboxes. The form also has a combo box in the header that filters the records according to ?agency type.?

What I want is to create labels or email only selected contacts within the filtered set, with the option to select them all at once using the "Select All" control.

The ?Select All? works great, until the form is filtered. The code behind ?Select All? continues to set all the checkboxes as true, even if they aren?t showing in the form. So when the ?Email Selected Contacts? or ?Create Mailing Labels for Selected Contacts? buttons are clicked, the results are not filtered at all.

I have tried to add additional criteria to the Where clause in the SQL statement of the On Click event to account for the filter, but I get the error ?Too few parameters. Expected 1? (error #3061). I don?t know if it?s because I have the syntax wrong or because I?m trying to do something I can?t.

Here?s the code that works:

展开 | 选择 | Wrap | 行号

推荐答案

错误消息表明您有一个拼写错误字段名称。


就个人而言,我会使用表单的Me.Filter属性来执行UPDATE查询,因为Access允许使用右键单击弹出菜单进行额外的过滤。


使用Me.Filter可以使用以下代码完成:
The error message is an indication that you have a typo in one of the field names.

Personally I would use the Me.Filter property of the form to execute the UPDATE query, as Access does allow additional filtering with the right-click pop-up menu.

Using the Me.Filter can be done with this code:
展开 | 选择 | Wrap | 行号


@ nico5038


感谢您的回复。我渴望对此有一些新的看法。


好​​的,所以我尝试了表单过滤器(查看我当前的代码后无法看到错字...)


我首先点击SelectAll复选框,它似乎工作。所有盒子都被选中了。但后来我试着过滤它。并得到了相同的错误 - 参数太少。


任何想法?
@nico5038
Thanks for the reply. I''m anxious to get some fresh perspective on this.

Okay, so I tried the form filter (after looking at my current code and unable to see the typo...)

When I first clicked the SelectAll checkbox, it seemed to work. All boxes were selected. But then I tried to filter it. And got the same error - Too Few Parameters.

Any ideas?


在我看来,我们首先要检查SQL。


最好的方法是在代码中放置一个断点(例如,点击左侧标尺获取一个点)并执行代码直到strSQL被填满。下一个类型在即时窗口中:


? strSQL


打印字符串并复制结果。


接下来打开查询编辑器,创建一个没有表的新查询并切换到SQL模式。发布SQL执行它。 Access现在会弹出一个窗口,询问你在桌子上找不到的特定字段的值。


Nic; o)
Looks to me we first have to check the SQL.

The best way is to place a break point in the code (e.g. click left ruler for getting a dot) and execute the code till the strSQL is filled. Next type in the immediate window:

? strSQL

to get the string printed and copy the result.

Next open the query editor, create a new query without tables and switch to SQL mode. There post the SQL en execute it. Access will now give a pop-up window asking the value for a specific field it doesn''t find i your table(s).

Nic;o)


这篇关于过滤器无法使用“全选”复选框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆