以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]重复值筛选  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=76545)

--  作者:wusim
--  发布时间:2015/10/31 14:31:00
--  [求助]重复值筛选
筛选表A中出厂编号或注册代码的重复值,怎样改下面的语句 Syscmd.Filter.ShowSameValues() 即查找表A中出厂编号相同或者注册代码相同的记录
[此贴子已经被作者于2015/10/31 14:33:38编辑过]

--  作者:Hyphen
--  发布时间:2015/10/31 14:59:00
--  
一次只能筛选一列,筛选前用代码选中列所在的单元格。多列只能循环所有行进行判断
--  作者:wusim
--  发布时间:2015/10/31 15:19:00
--  
Tables("表A").RepeatFilter("出厂编号", 0) 与Tables("表A").RepeatFilter("注册代码", 0) 能不能将各自的记录筛选出来且合并相同的记录。
[此贴子已经被作者于2015/10/31 15:36:34编辑过]

--  作者:Hyphen
--  发布时间:2015/10/31 15:55:00
--  

参考http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=71166&authorid=0&page=0&star=1

 


--  作者:wusim
--  发布时间:2015/10/31 16:12:00
--  
根据参考在

beforeSaveDataRow事件

改成:

Dim dr As DataRow =e.DataRow

Dim filter As String = "1=1"

If dr.IsNull("出厂编号") Then

    filter &= " and 出厂编号 is null"

Else

    filter &= " and 出厂编号 = \'" & dr("出厂编号") & "\'"

End If

If dr.IsNull("注册代码") Then

    filter &= " and 注册代码 is null"

Else

    filter &= " and 注册代码 = \'" & dr("注册代码") & "\'"

End If

If e.DataTable.Compute("Count([_Identify])",filter) > 1 Then

    MessageBox.Show("已经存在相同的出厂编号或注册代码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

    e.cancel = True

End If

但提示错误代码:

Dim dr As DataRow =e.DataRow


--  作者:wusim
--  发布时间:2015/10/31 16:47:00
--  
没有弹出提示
--  作者:Hyphen
--  发布时间:2015/10/31 16:47:00
--  
代码没有问题,我测试通过。重新打开项目。不行就上传测试例子
--  作者:wusim
--  发布时间:2015/10/31 17:32:00
--  
5楼的代码只是当出厂编号与注册代码同时重复时,才能提示,我是要当出厂编号或者注册代码作任一个出现重复就提示。即当出厂编号重复了,但注册代码没有重复,应提示。当注册代码重复了,但出厂编号没有重复,应提示。当出厂编号与注册代码同时是重复,应提示。
--  作者:Hyphen
--  发布时间:2015/10/31 17:58:00
--  

只能分开判断,先单列判断,再多列同时判断

 

 

 


--  作者:wusim
--  发布时间:2015/10/31 20:02:00
--  

用以下代码也不行,怎样改才行

Dim dr As DataRow =e.DataRow

Dim filter As String = "1=1"

If dr.IsNull("出厂编号"Then

    filter &" and 出厂编号 is null"

Else

    filter &" and 出厂编号 = \'" & dr("出厂编号"& "\'"

End If

If e.DataTable.Compute("Count([_Identify])",filter) > 1 Then

    MessageBox.Show("已经存在相同的出厂编号!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

    e.cancel = True

Else

If dr.IsNull("注册代码"Then

    filter &" and 注册代码 is null"

Else

    filter &" and 注册代码 = \'" & dr("注册代码"& "\'"

End If

If e.DataTable.Compute("Count([_Identify])",filter) > 1 Then

    MessageBox.Show("已经存在相同的注册代码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

    e.cancel = True

End If

End If

[此贴子已经被作者于2015/10/31 20:02:35编辑过]