求助,窗口按钮代码,实现筛选出列名含_连(超过50个含_连的列)的所有列值大于文本框里x的行下面代码超过50个含_连的列时,失效,求修复
Dim TB As WinForm.TextBox = e.Form.Controls("TextBox1")
If TB.Text <> "" Then
Dim s As String = "1=1 "
For Each C As Col In Tables("表A").Cols
If C.Name.Contains("_连") Then
s = s & " and " & C.Name & " >= " & TB.Text
End If
Next
MessageBox.Show(s)
Tables("表A").Filter = s
Else
MessageBox.Show(123)
End If
[此贴子已经被作者于2024/7/28 11:29:22编辑过]
表达式都是有长度限制的。
1、改为使用SQL查询(网上查了一下,access的sql语句最长65,536字符,SQL Server 2016及之前的版本限制为128 MB,SQL Server 2017及之后的版本提升到了250 MB)
2、遍历所有行所有列逐个判断
试试
Dim TB As WinForm.TextBox = e.Form.Controls("TextBox1")
If TB.Text <> "" Then
Dim s As String = "1=1 "
For Each C As Col In Tables("表A").Cols
If C.Name.Contains("_连") Then
s = s & " and " & C.Name & " >= " & TB.Text
End If
Next
MessageBox.Show(s)
dataTables("表A").loadFilter = s
dataTables("表A").load
Else
MessageBox.Show(123)
End If
Dim TB As WinForm.TextBox = Forms("窗口1").Controls("TextBox1")
If TB.Text <> "" Then
Dim 列名集 As New List(Of String)(Tables("表A").cols.where(Function(列) 列.name.Contains("连")).select(Function(列) 列.name & ">" & TB.Text))
Tables("表A").Filter = String.join(" and ", 列名集)
End If