Dim dt1,dt2 As New Date
dt1 = e.Form.Controls("DateTimePicker1").text '读取起始日期控件的值
dt2 = e.Form.Controls("DateTimePicker2").text '读取结束日期控件的值
'利用各控件的值,得出筛选条件表达式
Dim Filter,fhdw,shdw,hm,ch As String
fhdw = e.Form.Controls("发货单位").text
shdw = e.Form.Controls("收货单位").text
hm = e.Form.Controls("货名").text
ch = e.Form.Controls("车号").text
If fhdw <> "" And fhdw <>"发货单位" Then
filter = "发货单位 = '" & fhdw & "'" & " And "
End If
If shdw <> "" And shdw <> "收货单位" Then
filter = filter & "收货单位 = '" & shdw & "'" & " And "
End If
If hm <> "" And hm <> "货名"Then
filter = filter & "货名 = '" & hm & "'" & " And "
End If
If ch <> "" And ch <> "车号" Then
filter = filter & "车号 = '" & ch & "'" & " And "
End If
Filter = filter & "更新时间 >= '" & dt1 & "' And 更新时间 <= '" & dt2 & "'"
'后台读取符合条件的记录
Tables("明细查询_Table1").DataSource = DataTables("称重信息")
Tables("明细查询_Table1").Sort = "更新时间 DESC"
DataTables("称重信息").LoadFilter = Filter
‘Dim g As New Subtotalgroup '定义一个新的分组
’g.GroupOn = "*" '分组列为所有列
‘g.TotalOn = "净重" '对净重进行统计
’With Tables("称重信息")
‘ .SubtotalGroups.Clear() '清除原有的分组
’ .SubtotalGroups.Add(g) '加入刚刚定义的分组
‘ .Subtotal() '生成汇总模式
’End With
DataTables("称重信息").Load()