以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  遍历问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=73731)

--  作者:一笑
--  发布时间:2015/8/25 15:14:00
--  遍历问题
窗口中“开始”和“结束”为DateTimePicker,然后遍历“驻外”表,计算“事务主表”中天数,填入“驻外”表中“天数”列,但只能进行到第一行,求解,谢谢!
Dim filter As String
With e.Form.Controls("开始")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "事务时间 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("结束")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "事务时间 <= #" & .Value & "#"
    End If
End With
For Each dr As DataRow In DataTables("驻外").DataRows
If filter > ""
    Filter = filter & "and 接收者 Like \'%" & dr("姓名") & "%\' "
Else
    \'Filter = "接收者 Like \'%" & dr("姓名") & "%\' "
End If
dr("天数") = DataTables("事务主表").Compute("sum(天数)", Filter )
Next

--  作者:大红袍
--  发布时间:2015/8/25 15:20:00
--  
For Each dr As DataRow In DataTables("驻外").DataRows
    Dim temp As String
    If filter > ""
        temp = filter & "and 接收者 Like \'%" & dr("姓名") & "%\' "
    Else
        temp = "接收者 Like \'%" & dr("姓名") & "%\' "
    End If
    dr("天数") = DataTables("事务主表").Compute("sum(天数)", temp)
Next