栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

返回与值部分匹配的记录

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

返回与值部分匹配的记录

有一种访问方法!

如果您在表单上具有“过滤器”控件,那么为什么不使用Application.buildCriteria方法,该方法将允许您将过滤条件添加到字符串中,然后从该字符串中进行过滤,并构建WHERe条款在飞行中?

selectClause = "SELECT TabCustomers.* FROM TabCustomers"if not isnull(Forms!FrmSearchCustomer!SearchMember) then    whereClause = whereClause & application.buildCriteria(your field name, your field type, your control value) &  " AND "endifif not isnull(Forms!FrmSearchCustomer!SearchFore) then    whereClause = whereClause & application.buildCriteria(...) &  " AND "endifif not isnull(Forms!FrmSearchCustomer!SearchLast) then    whereClause = whereClause & application.buildCriteria(...) &  " AND "endifif not isnull(Forms!FrmSearchCustomer!SearchDate) then    whereClause = whereClause & application.buildCriteria(...) & " AND "endif--get rid of the last "AND"if len(whereClause) > 0 then     whereClause = left(whereClause,len(whereClause)-5)     selectClause = selectClause & " WHERe " & whereClauseendif-- your SELECT instruction is ready ...

编辑:buildCriteria将返回(例如):

  • 'field1 = "GR"'
    当您在控件中键入“ GR”时
  • 'field1 LIKE "GR*"'
    当您键入
    "GR*"
    控件时
  • 'field1 LIKE "GR*" or field1 like "BR*"'
    如果您键入
    'LIKE "GR*" OR LIKE "BR*"'
    控件

PS:如果表单上的“过滤器”控件始终具有相同的语法(比如说“ search_fieldName”,其中“
fieldName”对应于基础记录集中的字段)并且始终位于同一区域(比如说formHeader),然后可以编写一个函数,该函数将自动为当前表单生成一个过滤器。然后可以将此过滤器设置为表单过滤器,或用于其他用途:

For each ctl in myForm.section(acHeader).controls    if ctl.name like "search_"        fld = myForm.recordset.fields(mid(ctl.name,8))        if not isnull(ctl.value) thenwhereClause = whereClause & buildCriteria(fld.name ,fld.type, ctl.value) & " AND "        endif    endifnext ctlif len(whereClause)> 0 then ...


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/441547.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号