If e.Form.Controls("DateTimePicker1").Value Is Nothing OrElse e.Form.Controls("DateTimePicker2").Value Is Nothing Then
MessageBox.Show("请输入开始日期和结束日期")
Return
End If
Dim dt1 As Date = e.Form.Controls("DateTimePicker1").Value
Dim dt2 As Date = e.Form.Controls("DateTimePicker2").Value
If dt1 > dt2 Then
MessageBox.Show("开始日期不能晚于结束日期")
Return
Else
Dim Filter As String
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then
Tables("表A").Filter = Filter
End If
Dim g As New GroupTableBuilder("表C", DataTables("表A"))
g.Groups.AddDef("日期", "月")
g.Groups.AddDef("物品名称")
g.Totals.AddDef("重量")
g.Totals.AddDef("金额")
g.Totals.AddDef("运费")
g.Totals.AddDef("合计")
g.Filter=Filter
g.SubTotal = True
g.Build()
MainTable = Tables("表C")
End If
统计按钮里的代码这样行不.