以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]表A,基于字段1,字段2,字段3显示重复值如何写  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=107764)

--  作者:ymjr2011
--  发布时间:2017/10/9 16:11:00
--  [求助]表A,基于字段1,字段2,字段3显示重复值如何写
表A,基于字段1,字段2,字段3显示重复值如何写
--  作者:有点甜
--  发布时间:2017/10/9 16:20:00
--  

 

[此贴子已经被作者于2017/10/9 16:21:45编辑过]

--  作者:有点甜
--  发布时间:2017/10/9 16:23: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("表A").Select("", cs)
   
    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 Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
        idx_temp &= dr("_Identify") & ","
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("表A").filter = "_Identify in (" & idx.trim(",") & ")"


--  作者:乡里出城
--  发布时间:2017/12/17 11:05:00
--  
删除多出的重复项(必须剩下唯一条不能删),应该如何写,我改成下面的代码不对,删除了所有重复的行,一条不剩
DataTables("表A").DeleteFor("_Identify in (" & idx.trim(",") & ")")

--  作者:有点甜
--  发布时间:2017/12/17 20:03:00
--  

参考

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=107487&skin=0