我的“勤务排班管理窗口”
如图,有“去重”按钮
重复排班的判定依据为:日期,飞机号,航班号,航段,安全员 这5个字段同时重复才判定为重复数据。
点击去重按钮,
自动将重复的数据自动合并为一条(只显示一条)。
请问去重按钮的代码如何编写。
绑定表名为“勤务信息表”
此主题相关图片如下:1.png
之前提问过此问题,您回答
我自己修改代码为:
'----删除重复,参考代码-------
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("", cs)
Dim flag As Boolean = False
If pdr IsNot Nothing Then
For Each c As String In cs.split(",")
If pdr(c).replace(" ","") <> dr(c).replace(" ", "") Then
flag = True
Exit For
End If
Next
If flag Then
If count > 1 Then
idx &= idx_temp
End If
count = 1
idx_temp = ""
Else
count += 1
idx_temp &= dr("_Identify") & ","
End If
Else
count += 1
End If
pdr = dr
Next
If count > 1 Then
idx &= idx_temp
End If
Tables("勤务信息表").Filter = "_Identify not In (" & idx.trim(",") & ")"
DataTables("勤务信息表").DeleteFor("_Identify not In (" & idx.trim(",") & ")")
运行后错误如下
此主题相关图片如下:2.png
[此贴子已经被作者于2017/7/30 23:19:34编辑过]