Dim Filter As String
With e.Form.Controls("ComboBox4")
If .Value IsNot Nothing Then
Filter = "姓名 = '" & .Value & "'"
End If
End With
With e.Form.Controls("DateTimePicker5")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker6")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
Tables("计件明细").Filter = Filter
Tables("计时明细").Filter = Filter
Tables("其它工资").Filter = Filter
End If
DataTables("计件工资").DataRows.Clear()
For Each xm As String In DataTables("计件明细").GetValues("姓名")
Dim fdr As DataRow = DataTables("计件工资").find("[姓名] = '" & xm & "'")
If fdr Is Nothing Then
fdr = DataTables("计件工资").AddNew
fdr("姓名") = xm
End If
fdr("计件工资") = Tables("计件明细").compute("sum(计件工资)", "姓名 = '" & xm & "'")
Next
For Each xm As String In DataTables("计时明细").GetValues("姓名")
Dim fdr As DataRow = DataTables("计件工资").find("[姓名] = '" & xm & "'")
If fdr Is Nothing Then
fdr = DataTables("计件工资").AddNew
fdr("姓名") = xm
End If
fdr("其它工资") = Tables("计时明细").compute("sum(计时工资)", "姓名 = '" & xm & "'")
Next
For Each xm As String In DataTables("其它工资").GetValues("姓名")
Dim fdr As DataRow = DataTables("计件工资").find("[姓名] = '" & xm & "'")
If fdr Is Nothing Then
fdr = DataTables("计件工资").AddNew
fdr("姓名") = xm
End If
fdr("奖励") = Tables("其它工资").compute("sum(奖励)", "姓名 = '" & xm & "'")
fdr("罚款") = Tables("其它工资").compute("sum(罚款)", "姓名 = '" & xm & "'")
fdr("房租") = Tables("其它工资").compute("sum(房租)", "姓名 = '" & xm & "'")
fdr("扣水电") = Tables("其它工资").compute("sum(扣水电)", "姓名 = '" & xm & "'")
fdr("保险") = Tables("其它工资").compute("sum(保险)", "姓名 = '" & xm & "'")
fdr("扣其它") = Tables("其它工资").compute("sum(扣其它)", "姓名 = '" & xm & "'")
Next
该代码提取了三个table的数据,请老师帮忙改改,“计件工资”表只新增3个table出现的姓名,没有出现的不要新增
[此贴子已经被作者于2017/8/21 21:41:18编辑过]