全表搜索表单 - 的Microsoft Access 2010 [英] Entire Table Search Form - Microsoft Access 2010

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

问题描述

我想创建一个可以从一个表的基础上通过从组合框中用户所选择的表中的时间搜索搜索表单。我有一个文本框称为searchCriteria和组合框被称为TableList。我们的想法是,如果用户想查询customer_table,她会在组合框中选择customer_table,在文本框中输入自己的搜索条件,和preSS搜索按钮。如果她想查询order_table,她会从组合框等选择该表。我想查询有关进入条件的所有完整记录返回。因此,举例来说,如果用户从客户表中查找詹姆斯,我想的完全记录(所有字段)回来,在那里的标准詹姆斯是present:

I am trying to create a search form that can search from one table at a time based on the table selected by the user from a combo-box. I have a text box called searchCriteria and the combo-box is called TableList. The idea is that if the user wanted to search customer_table, she would select "customer_table" in the combo box, enter her search criteria in the text box, and press the search button. If she wanted to search order_table, she would select that table from the combo-box and so on. I would like the query to return all full records pertaining to the criteria entered. So, for example, if the user searched "James" from the customer table, I would like the full records (all fields) returned where the criteria "James" is present:

 
    Company               |   First Name    |   Last Name   |   Account #   |   Sales Rep
    Jammy Juice           |   James         |   Dan         |   555         |   Jim Halbert
    Jameson Car Shop      |   Tom           |   Cramb       |   556         |   Dwight Smiles
    Landon Refrigeration  |   Bob           |   McVance     |   557         |   James Bland

这是我的理解,这将需要一些VBA编写一个查询......

From my understanding, this will require some VBA to write a query…

我假设查询会是这样的: 选择T * FROM customer_table t其中(T *)::文LIKE'%詹姆士%';

I am assuming the query would be something like the following: SELECT t.* FROM customer_table t WHERE (t.*)::text LIKE '%James%';

当进入(詹姆斯)的字符串,表名(customer_table)由用户输入。

Where the string entered (James) and the table name (customer_table) are entered by the user.

简单地说,我有麻烦的表格数据(表名和搜索文本)到我的查询。

Simply, I'm having trouble getting the form data (the table name and search text) into my query.

有谁知道如何在Microsoft Access 2010中实现这一点?任何有识之士将AP preciated。

Does anyone know how to implement this in Microsoft Access 2010? Any insight would be appreciated.

推荐答案

的任何字符序列的通配符的访问是 * 不是 。如果你想搜索的访问各个领域,那么你可以串接所有字段:

The any sequence of characters wildcard in Access is * not %. If you want to search all fields in Access then you could concatenate all the fields:

WHERE [FirstName] & [Surname] & [City] & [Address] 
LIKE "'*" & Forms!frmSearch!txtFind & "*'"

您可以分隔字段具有鲜明的性格,prevent找到域之间重叠的话。

You might separate the fields with a distinct character, to prevent finding words that overlap between the fields.

或者个人,但效率较低:

Or, individually, but less efficient:

WHERE [FirstName] Like "'*" & Forms!frmSearch!txtFind & "*'" 
OR [Surname] Like "'*" & Forms!frmSearch!txtFind & "*'" 
OR [Address] Like "'*" & Forms!frmSearch!txtFind & "*'" 

(我不知道在哪里(T *)::文是从哪里来的,但无法访问。)

(I don't know where (t.*)::text came from, but it is not Access.)

所以,你首先需要发现他们已经选择了所有现场名称表。你可以得到的TableDef 因为他们通过字段集合,以获得现场选择和环路的表名名字。还有其他的方法可以做到这一点。例如,的getSchema

So you will firstly need to discover all the field-names for the table they have selected. You can obtain the TableDef for the table-name they have selected and loop through its Fields collection to obtain the field-names. There are other ways to do this. For example, GetSchema.

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

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