以文本方式查看主题

-  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=47652)

--  作者:hz1717
--  发布时间:2014/3/14 11:00:00
--  求助:提取不重复值的个数
老师好:
     我希望在主表(表A)中 “料号数量”列  显示     子表中(表B)关联行的  “物料编号”列的 不重复值的  个数。
     应该如何写代码

--  作者:Bin
--  发布时间:2014/3/14 11:03:00
--  
用下拉列表显示吗?

PrepareEdit事件

If e.Col.name="料号数量" Then
   e.Col.ComboList=DataTables("子表").GetComboListString("物料编号","关联列=\'" & e.Row("关联列") & "\'")
End If


--  作者:hz1717
--  发布时间:2014/3/14 11:05:00
--  
不用下拉显示,直接在 “料号数量”列  显示   “物料编号”列的数量



--  作者:狐狸爸爸
--  发布时间:2014/3/14 11:10:00
--  

在子表的DataColChanged事件写入:

 

if e.col.name  = "物料编号" then

   dim pr as datarow = e.datarow.getparent(”父表“)

   if  pr isnot nothing then

      pr(”料号数量“) = DataTables("子表").GetValues("物料编号","关联列=\'" & e.dataRow("关联列") & "\'").Count

   end if

end if

 

在子表的DatarowDeleting事件写入:

e.datarow("物料编号") = ""

 

 

建议看看:

http://www.foxtable.com/help/topics/2649.htm

 


--  作者:Bin
--  发布时间:2014/3/14 11:10:00
--  
那你希望实现的方式是怎么样的呢?