以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  删除重复出错(已解决)  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=115079)

--  作者:thz706
--  发布时间:2018/2/28 17:07:00
--  删除重复出错(已解决)

根据帖子《如何标注出多列内容相同的行》(链接http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=114307&skin=0)中有点甜老师给予的删除重复代码稍作修改,在删除重复合同编号时,多删除了序号8、合同编号为2016GTE01,不知道问题出在哪里,请老师赐教。

附件是fox文件。

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:去重出错.zip

[此贴子已经被作者于2018/3/1 8:48:42编辑过]

--  作者:有点甜
--  发布时间:2018/2/28 17:15:00
--  

改成这样

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "合同编号"
For Each dr As DataRow In DataTables("去重复合同编号").Select("", "合同编号")
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag OrElse pdr Is Nothing Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("去重复合同编号").filter = "_Identify in (" & idx.trim(",") & ")"

\'Tables("去重复合同编号").filter = "_Identify not in (" & idx.trim(",") & ")"  \'显示唯一值


--  作者:thz706
--  发布时间:2018/3/1 8:48:00
--  
谢谢甜老师