Microsoft Access 2010中的多个文本筛选器 [英] Multiple text filters in Microsoft Access 2010

查看:371
本文介绍了Microsoft Access 2010中的多个文本筛选器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用两个文本框StaffTotalSearchText1和StaffTotalSearchText2筛选数据.

I would like to filter through my data with two text boxes, StaffTotalSearchText1 and StaffTotalSearchText2.

我了解到只有最新的DoCmd.ApplyFilter命令适用,这意味着我不知道如何应用两个文本过滤器.

I understand that only the most recent DoCmd.ApplyFilter command appies, and that means I don't know how to apply two text filters.

找到解决方案-请参阅约翰尼的RecordSource代码 应用过滤器的一种方法是执行已加载的数据(RecordSource)-仍然允许使用"DoCmd.ApplyFilter".

Solution found - see Johnny's RecordSource code One way of applying a filter is to do it do the loaded data (RecordSource) - still allowing a "DoCmd.ApplyFilter" to be used.

我创建了一个锁定过滤器1"按钮.启用后,将应用过滤器;禁用时,没有过滤器.

I've created a "lock filter 1" button. When enabled, the filter applies; when disabled, there is no filter.

Johhny的答案具有正确的代码,可以在加载数据时对其进行过滤.

Johhny's answer has the correct code to filter the loaded data upon loading it.

推荐答案

尝试一下:

Me.RecordSource = "SELECT * FROM StaffTable " & _
"WHERE [Forename] Like '*" & [Forms]![StaffTotalQuery]![StaffTotalSearchText1] & "*' " & _
   "Or [Surname] Like '*" & me![StaffTotalSearchText1] & "*' " & _
   "Or [ProfessionalID] Like '*" & me![StaffTotalSearchText1] & "*'"

假设您要指向正确的对象(我想Forename在不同的表单上?这是您唯一通过表单名引用的对象),这应该可以工作.

Assuming you're pointing to the correct objects (I'm guessing Forename is on a different form? It's the only one you're referencing by form name), this should work.

这篇关于Microsoft Access 2010中的多个文本筛选器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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