Dim dt1 As Date = e.Form.Controls("DateTimePicker1").Value Dim dt2 As Date = e.Form.Controls("DateTimePicker2").value Dim filter As String = "1=1" If dt1 <> Nothing Then filter &= " and 日期 >= #" & dt1 & "#" End If If dt2 <> Nothing Then filter &= " and 日期 <= #" & dt2 & "#" End If e.Form.Controls("TextBox1").Text = DataTables("订单").Compute("sum(数量)", filter)