搜索代码...如何使用代码/ SQL进行过滤 [英] Search code...how to filter using code/SQL

查看:67
本文介绍了搜索代码...如何使用代码/ SQL进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次嗨人们。


这个论坛对我来说是一个严重的帮助...我相信你知道它是怎么回事......你在处理方面做得很好wham访问!你遇到了一些你无法想象的东西 - 如果你一点都不急......!


我有一张主表格,基于我的主要内容表(产品)。这个主窗体有一个子窗体(基于一个主要基于Products表的查询,以及其他几个来抓住相关数据(客户名而不是ID等))。


产品表中的一个字段称为HANDLE,本质上是一个简化搜索的组成字段 - 它是表格中几个字段的混合物。


当我单击SEARCH时,我希望子表单根据用户点击(未绑定)文本框的HANDLE显示结果。这可以使用宏来运行过滤器,但我需要一些东西,嗯,更坚固,更详细和可控。


我知道有一种方法可以使用通过代码中的变量输入的SQL ...是否有某些通用代码可以告诉我如何执行此操作。


很抱歉复杂,但我想尽可能多地给你信息。


谢谢。

Stonward the Troubled。

Hi again People.

This Forum has been a serious help for me...I''m sure you know how it is...you get pretty good at handling Access when wham! you come across something you just can''t figure - and if you''re in a hurry at all....!

I have a Main Form, based upon my main table (products). This main form has a subform (based upon a query that is based primarily upon the Products table, plus a few others to grab hold of related data (customer names rather than ID etc)).

One of my fields of the products table is called HANDLE and is, essentially, a made up field to enable simpler searching - it''s an amalgam of several fields of the table.

When I click SEARCH, i want the subform to show the results based on the HANDLE the user taps into an (unbound) textbox. This works okay using a macro to run a filter, but I need something, um, firmer and more detailed and controllable.

I know there is a way using SQL entered via a variable in code...is there some ''generic'' code someone can show me as to how this may be done.

Sorry for the complexity, but i want to give you as much info as possible.

Thanks.

Stonward the Troubled.

推荐答案


再次嗨人们。


这个论坛对我来说是一个严肃的帮助......我相信你知道它是怎么回事......当你做到这一点时,你会非常善于处理Access!你遇到了一些你无法想象的东西 - 如果你一点都不急......!


我有一张主表格,基于我的主要内容表(产品)。这个主窗体有一个子窗体(基于一个主要基于Products表的查询,以及其他几个来抓住相关数据(客户名而不是ID等))。


产品表中的一个字段称为HANDLE,本质上是一个简化搜索的组成字段 - 它是表格中几个字段的混合物。


当我单击SEARCH时,我希望子表单根据用户点击(未绑定)文本框的HANDLE显示结果。这可以使用宏来运行过滤器,但我需要一些东西,嗯,更坚固,更详细和可控。


我知道有一种方法可以使用通过代码中的变量输入的SQL ...是否有某些通用代码可以告诉我如何执行此操作。


很抱歉复杂,但我想尽可能多地给你信息。


谢谢。

Stonward the Troubled。
Hi again People.

This Forum has been a serious help for me...I''m sure you know how it is...you get pretty good at handling Access when wham! you come across something you just can''t figure - and if you''re in a hurry at all....!

I have a Main Form, based upon my main table (products). This main form has a subform (based upon a query that is based primarily upon the Products table, plus a few others to grab hold of related data (customer names rather than ID etc)).

One of my fields of the products table is called HANDLE and is, essentially, a made up field to enable simpler searching - it''s an amalgam of several fields of the table.

When I click SEARCH, i want the subform to show the results based on the HANDLE the user taps into an (unbound) textbox. This works okay using a macro to run a filter, but I need something, um, firmer and more detailed and controllable.

I know there is a way using SQL entered via a variable in code...is there some ''generic'' code someone can show me as to how this may be done.

Sorry for the complexity, but i want to give you as much info as possible.

Thanks.

Stonward the Troubled.

我没有那么多,首先,有几个假设:

  1. [HANDLE] Field - SubForm中由各种值的汞合金组成的字段。
  2. 主窗体名称= frmMain。
  3. SubForm控件名称= subfSubForm 。
  4. 搜索按钮名称= cmdSearch。
  5. 文本框名称= txtSearchCriteria。
  6. SubForm = qryRecordSource的RecordSource。
  7. 主键主窗体上的字段= [PrimaryKey]。
  8. SubForm上的外键字段= [ForeignKey]。
  9. 使用的一种方法是修改SubForm的RecordSource以反映正确的外语关键字段,以及[HANDLE]字段中值的部分匹配,如txtSearchCriteria中的条目所示。
  10. 希望这是有道理的。
  1. [HANDLE] Field - Field in SubForm cosisting of an amalgam of various values.
  2. Main Form Name = frmMain.
  3. SubForm Control Name = subfSubForm.
  4. Search Button Name = cmdSearch.
  5. Text Box Name = txtSearchCriteria.
  6. RecordSource for the SubForm = qryRecordSource.
  7. Primary Key Field on Main Form = [PrimaryKey].
  8. Foreign Key Field on SubForm = [ForeignKey].
  9. One Method to use is to modify the RecordSource of the SubForm to reflect the proper Foreign Key Fields, as well as a Partial Match for Values in the [HANDLE] Field, as indicated by entries in txtSearchCriteria.
  10. Hope this makes sense.
展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


这就是我在说什么!谢谢ADezii!

当然!更改记录源 - 我从未发现如何正确使用该语法!


现在就试试吧。


再次使用Thanx。


Stonward the Impressed。
That''s what I''m talking about! Thanks ADezii!
Of course! Change the recordsource - I''d never have discovered how to get that syntax right!

Gonna try it now.

Thanx again.

Stonward the Impressed.


嗨。尝试(上面)代码并解决问题。外键是子表单的记录源的外来词?是对的吗?代码似乎没有看到子表单基于的查询...
Hi. Trying out (above) code and getting teething troubles. The Foreign Key is the foreign of the recordsource of the subform? is that right? The code doesn''t appear to ''see'' the query that the subform is based on...


这篇关于搜索代码...如何使用代码/ SQL进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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