Access 2010-以编程方式搜索表单 [英] Access 2010 - Search a form programmatically

查看:110
本文介绍了Access 2010-以编程方式搜索表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有一个Access 2010表单,该表单允许用户在雇员"表中的每个雇员上导航.

假设表单还包含一个TextBox txtId,用户可以在其中键入唯一标识员工的ID.单击确定按钮后,表单应显示与由键入的ID标识的员工相关的信息.

如何在不使用过滤器的情况下使用VB6做到这一点?

我希望宏SearchForRecord具有相同的效果,但是可以从Visual Basic中进行所有工作.

预先谢谢您.

Suppose we have an Access 2010 form that allows a user to navigate over every single employee in the table Employees.

Suppose also the form contains a TextBox txtId where the user can type the Id that uniquely identifies an employee. After clicking a button OK the form should show the information related to the employee identified by the typed id.

How can I do that using VB6 and without using filters?

I''d like the same effect the macro SearchForRecord has but doing all the work from Visual Basic.

Thank you in advance.

推荐答案

Access表单具有Filter FilterON 属性.只需将FilterOn 设置为True,并将Filter 属性设置为文本,就像在SQL Where子句(即Company LIKE "C*")中出现的一样.

An Access form has a Filter and an FilterON property. Just need to set the FilterOn to True and the Filter property to the text as would appear in a SQL Where clause (ie, Company LIKE "C*").

Me.Filter = "Company LIKE """ + CompanyFilter.Text + """"
Me.FilterOn = True



当表单仅显示一条记录或显示许多记录时,这也应该可以正常工作.



This should also work fine when form only shows a single record, or when it shows many records.


这篇关于Access 2010-以编程方式搜索表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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