窗口中“开始”和“结束”为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