左栏'); } else{ document.write('关闭左栏'); } }catch(e){alert(e);}
Foxtable(狐表)用户栏目专家坐堂 → 遍历不重复的行


  共有1923人关注过本帖树形打印复制链接

主题:遍历不重复的行

美女呀,离线,留言给我吧!
lfz123
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:530 积分:4613 威望:0 精华:0 注册:2018/3/24 18:04:00
遍历不重复的行  发帖心情 Post By:2019/4/18 15:10:00 [显示全部帖子]

原代码:
For Each dr As DataRow In dt.Select("凭证ID = '"& str & "'")  
Dim r1 As Row = Tables("凭证.凭证明细").AddNew()
r1("摘要") = "转:" & dr("申请单号") & dr("申请人") & ":" & dr("摘要")
r1("科目代码") = dr("借方代码")
r1("借方金额") = dt.Compute("sum(金额)","借方代码= '"& dr("借方代码") & "'and 凭证ID = '"& str & "'and 摘要 = '"& dr("摘要") & "'")
Next

还想加个遍历条件 : dt表的摘要不重复

新代码:

For Each zy As String In dt.GetValues("摘要","凭证ID = '"& str & "'")
    For Each dr As DataRow In dt.Select("凭证ID = '"& str & "'and 摘要 = '"& zy & "' ") '没有实现此功能
        Dim r1 As Row = Tables("凭证.凭证明细").AddNew()
        r1("摘要") = "转:" & dr("申请单号") & dr("申请人") & ":" & dr("摘要")
        r1("科目代码") = dr("借方代码")
        r1("借方金额") = dt.Compute("sum(金额)","借方代码= '"& dr("借方代码") & "'and 凭证ID = '"& str & "'and 摘要 = '"& dr("摘要") & "'")
    Next
Next

 回到顶部