想从主表A第三列,查找并导出包涵combobox1内容的一个临时表,但导出的不是我想要的效果!
表A如下:
此主题相关图片如下:主表.png
导出查询表如下图:
此主题相关图片如下:查询表.png
查询命令如下:
Dim dtb As New DataTableBuilder("查询")
Dim ta2 As DataTable
dtb.AddDef("第一列", Gettype(String), 32)' '班组型
dtb.AddDef("第三列", Gettype(String), 32)
ta2 = dtb.Build()
Dim Cols1() As String = {"第一列","第三列"}
Dim Cols2() As String = {"第一列","第三列"}
If e.Form.Controls("ComboBox1").value = ""
For Each dr1 As DataRow In DataTables("表A").Select("")
Dim dr2 As DataRow = DataTables("查询").AddNew()
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next
ElseIf e.Form.Controls("ComboBox1").value <> ""
For Each dr1 As DataRow In DataTables("表A").Select("第三列 Like '" & e.Form.Controls("ComboBox1").value & "' ")
Dim dr2 As DataRow = DataTables("查询").AddNew()
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next
End If
Tables("查询").Sort = "第一列" '排序
Dim sl As Integer = DataTables("表A").Compute("Count(第一列)","第三列 like '" & e.Form.controls("ComboBox1").text & " ' ")
e.Form.controls("TextBox1").text = sl
请各位老师费心!
谢谢!
[此贴子已经被作者于2021/8/18 11:01:59编辑过]