Rss & SiteMap

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

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

标题:筛选

1楼
1234567 发表于:2024/9/4 13:05:00
如何筛选出不同【零件编号】的最后【完成日期】行?
图片点击可在新窗口打开查看此主题相关图片如下:3.png
图片点击可在新窗口打开查看
2楼
狐狸爸爸 发表于:2024/9/4 14:12:00
例如:

sele ct 编号,max(日期)  from {表B} group by 编号
3楼
1234567 发表于:2024/9/4 15:45:00

我要找出零件编号为A,完成日期为最近的行,零件编号为B,完成日期为最近的行.......

是否采用For Each 语句,代码怎么写?

4楼
1234567 发表于:2024/9/4 17:20:00

Dim Filter As String = "零件编号 = ''"
Dim Products As List(Of String)
Products = DataTables("表A").GetValues("零件编号") '找出不同的零件编号
For Each Product As String In Products
Filter = Filter & " And "
Filter = Filter & "(零件编号 = '" & Product & "' AND 完成日期 = '" & Max(完成日期) & "')"'找出不同零件编号的最近完成日期行
 Next
If Filter > "" Then
    Tables("表A").Filter = Filter '筛选出不同零件编号的最近完成行
End If


老师,上述代码的思路是否正确,帮我改一下代码?

5楼
狐狸爸爸 发表于:2024/9/5 8:57:00
Dim drs As List(Of DataRow) = DataTables("表B").Select("", "编号,日期 Desc")
Dim rst As New List(Of DataRow)
Dim bh As String = ""
For Each dr As DataRow In drs
    If dr("编号") <> bh Then
        rst.Add(dr)
        bh = dr("编号")
    End If 
Next

rst就是要的结果。
6楼
1234567 发表于:2024/9/5 10:25:00
Dim drs As List(Of DataRow) = DataTables("表A").Select("", "零件编号,完成日期 Desc")
Dim rst As New List(Of DataRow)
Dim bh As String = ""
For Each dr As DataRow In drs
    If dr("零件编号") <> bh Then
        rst.Add(dr)
        bh = dr("零件编号")
        Dim Filter As String = "工艺单号 = ''"
        Filter = Filter & " And "
       Filter = Filter & "工艺单号 = '" & drs("工艺单号") & "'"
    End If
Next
If Filter > "" Then
    Tables("生产管理_Table01").Filter = Filter
End If

图片点击可在新窗口打开查看此主题相关图片如下:8.png
图片点击可在新窗口打开查看
7楼
狐狸爸爸 发表于:2024/9/5 10:51:00
Filter = Filter & "工艺单号 = '" & dr("工艺单号") & "'"


8楼
1234567 发表于:2024/9/5 11:01:00

Dim drs As List(Of DataRow) = DataTables("表A").Select("", "零件编号,完成日期 Desc")
Dim rst As New List(Of DataRow)
Dim bh As String = ""
For Each dr As DataRow In drs  
    If dr("零件编号") <> bh Then
        rst.Add(dr)
        bh = dr("零件编号")
        Dim Filter As String = "工艺单号 = ''"
        Filter = Filter & " And "
        Filter = Filter & "工艺单号 = '" & dr("工艺单号") & "'"
        If Filter > "" Then
        Tables("表A").Filter = Filter
        End If
    End If 
Next

筛选的结果生成的表是空的

9楼
狐狸爸爸 发表于:2024/9/5 11:25:00
检查一下合成的Filter内容是什么
10楼
1234567 发表于:2024/9/5 12:27:00

Dim drs As List(Of DataRow) = DataTables("表A").Select("", "零件编号,完成日期 Desc")
Dim rst As New List(Of DataRow)
Dim bh As String = ""
For Each dr As DataRow In drs
    If dr("零件编号") <> bh Then
        rst.Add(dr)
        bh = dr("零件编号")
        MsgBox(bh)
        Dim Filter As String = "工艺单号 = ''"
         MsgBox(Filter)
        Filter = Filter & " or "
         MsgBox(Filter)
        Filter = Filter & "工艺单号 = '" & dr("工艺单号") & "'"
         MsgBox(Filter)
        If Filter > "" Then
        Tables("表A").Filter = Filter
        End If
    End If
Next

合成的Filter分别是如下内容,我希望的合成结果是工艺单='' or工艺单='A-03'or工艺单='B-03'

 A       工艺单=''      工艺单='' or     工艺单='' or工艺单='A-03'   

 B       工艺单=''      工艺单='' or     工艺单='' or工艺单='B-03'

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

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

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