Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共10 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:请教loadfilter加载代码

1楼
exonjee 发表于:2009/9/21 21:24:00

为什么下面代码不能进行匹配加载数据,
Dim txb2 As WinForm.TextBox = e.form.Controls("TxtB2")
With dataTables("炉次")
    .loadFilter ="[炉次编号] like '*" & txb2.value & "*'"
    .load()
End With


txb2必需输入完整的字符后才能加载。

Dim txb2 As WinForm.TextBox = e.form.Controls("TxtB2")
With dataTables("炉次")
    .loadFilter ="[炉次编号] like 'ASBC123'"
    .load()
End With

2楼
狐狸爸爸 发表于:2009/9/21 21:26:00

LIKE运算符

LIKE运算符用于将指定表达式的值和一个模式字符串进行比较,判断两者是否匹配。

你在LIKE 操作样式里可以使用多种通配符,如下所示:

%(百分号)
匹配任意个数的字符。

[](方括号)
匹配任何被包括在方括号里面的单个字符。

!(感叹号)
匹配任何不属于被方括号所包含的字符。

-(连字符)
用于指定一个字符范围。

例如:

Like 'C%',

表示以字符C开始的值。

Like 'P[A-F]%'

表示以字母P开头、而其后接着介于A到F之间的任何一个字母,最后是任意个数的任何字符。

找出客户表中的贸易公司:

SELECT * FROM {客户} WHERE 公司名称 LIKE '%贸易%'

找出客户ID不是以字母A或B字母的客户:

SELECT * FROM {客户} WHERE 客户ID LIKE '[!AB]%'

找出客户ID以字母A、B、C、D中任何一个开头的客户:

SELECT * FROM {客户} WHERE 客户ID LIKE '[A-D]%'

可以利用NOT关键词进行反向操作,例如:

SELECT * FROM {客户} WHERE 公司名称 NOT LIKE '%贸易%'

找出所有非贸易公司。 

3楼
exonjee 发表于:2009/9/21 21:50:00

为什么开始日期和结束日期只输入一个时会报错,代码哪块有问题?

Dim tpk1 As WinForm.DateTimePicker = e.form.Controls("datetimepicker1")
Dim tpk2 As WinForm.DateTimePicker = e.form.Controls("datetimepicker2")
if  tpk2.text is nothing and tpk1.text isnot nothing then
    With dataTables("炉次")
         .loadFilter =  "[日期] =#" & tpk1.text & "#"
         .load()
    End With
end if
if tpk1.text isnot nothing and tpk2.text isnot nothing then
    With dataTables("炉次")
         .loadFilter =  "[日期] >=#" & tpk1.text & "# and [日期] <=#" & tpk2.text & "#"
         .load()
    End With
end if

[此贴子已经被作者于2009-9-21 21:57:38编辑过]
4楼
狐狸爸爸 发表于:2009/9/22 7:45:00
代码中的Text换成Value,例如:

if  tpk2.Value is nothing and tpk1.Value isnot nothing then
5楼
epilight 发表于:2009/9/22 8:51:00

学习

[此贴子已经被作者于2009-9-22 8:51:12编辑过]
6楼
blackzhu 发表于:2009/9/22 8:52:00

这段代码是模糊筛选的

CurrentTable.Filter = ""
Dim Filter As String
With e.Form.Controls("ListBox1")
    If .Value IsNot Nothing Then
        Filter = "'*" & .Value & "*'"
    End If
End With
If Filter > "" Then
    Tables("常用代码").Filter = "cz Like " & Filter & " Or dm Like " & Filter & " Or sm Like " & Filter & " Or lx Like " & Filter & " Or dmwz Like " & Filter 




我想问一下改成模糊加载应该怎么改?

7楼
exonjee 发表于:2009/9/22 8:58:00
以下是引用blackzhu在2009-9-22 8:52:00的发言:

这段代码是模糊筛选的

CurrentTable.Filter = ""
Dim Filter As String
With e.Form.Controls("ListBox1")
    If .Value IsNot Nothing Then
        Filter = "'*" & .Value & "*'"
    End If
End With
If Filter > "" Then
    Tables("常用代码").Filter = "cz Like " & Filter & " Or dm Like " & Filter & " Or sm Like " & Filter & " Or lx Like " & Filter & " Or dmwz Like " & Filter 




我想问一下改成模糊加载应该怎么改?


这样试下

CurrentTable.Filter = ""
Dim Filter As String
With e.Form.Controls("ListBox1")
    If .Value IsNot Nothing Then
        Filter = "'%" & .text & "%'"
    End If
End With
If Filter > "" Then
    Tables("常用代码").Filter = "cz Like " & Filter & " Or dm Like " & Filter & " Or sm Like " & Filter & " Or lx Like " & Filter & " Or dmwz Like " & Filter

8楼
blackzhu 发表于:2009/9/22 10:21:00
以下是引用exonjee在2009-9-22 8:58:00的发言:


这样试下

CurrentTable.Filter = ""
Dim Filter As String
With e.Form.Controls("ListBox1")
    If .Value IsNot Nothing Then
        Filter = "'%" & .text & "%'"
    End If
End With
If Filter > "" Then
    Tables("常用代码").Filter = "cz Like " & Filter & " Or dm Like " & Filter & " Or sm Like " & Filter & " Or lx Like " & Filter & " Or dmwz Like " & Filter

  我要模糊加载。"loadfilter"

9楼
exonjee 发表于:2009/9/22 11:12:00
dataTables("常用代码").loadFilter = "cz Like " & Filter & " Or dm Like " & Filter & " Or sm Like " & Filter & " Or lx Like " & Filter & " Or dmwz Like " & Filter
dataTables("常用代码").load()
10楼
blackzhu 发表于:2009/9/22 11:32:00
以下是引用exonjee在2009-9-22 11:12:00的发言:
dataTables("常用代码").loadFilter = "cz Like " & Filter & " Or dm Like " & Filter & " Or sm Like " & Filter & " Or lx Like " & Filter & " Or dmwz Like " & Filter
dataTables("常用代码").load()

这个我试过的,不行!

共10 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02637 s, 2 queries.