没有数据库无法测试。代码改为
Dim d1 As Date = e.Form.Controls("H").Value
Dim d2 As Date = e.Form.Controls("I").Value
Dim s As String = e.Form.Controls("J").Value
If d1 = Nothing Or d2 = Nothing Then
MessageBox.Show("日期都不能为空","友情提醒",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Else
With DataTables("生产记录")
.LoadFilter = "日期>=#" & d1 & "# and 日期<=#" & d2 & "# and 配方名称 like '%" & s & "%'"
.Load()
End With
Dim b As New GroupTableBuilder("统计表1",DataTables("生产记录"))
b.Groups.AddDef("原料名称")
b.Totals.AddDef("设定值")
b.Totals.AddDef("实际值")
b.Totals.AddDef("误差值")
b.Build '生成统计表
MainTable = Tables("统计表1")
End If