以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  为什么下面的代码点击按钮两下才能实现目标  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=146366)

--  作者:wujie
--  发布时间:2020/2/22 11:33:00
--  为什么下面的代码点击按钮两下才能实现目标
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
Dim b As New GroupTableBuilder("统计表1",DataTables("生产记录"))
If d1 = Nothing Or d2 = Nothing Then
MessageBox.Show("日期都不能为空","友情提醒",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Else
    With DataTables("生产记录")
         .LoadFilter = "日期>=#" & d1 & "# and 日期<=#" & d2 & "# and 配方名称 like \'%" & s & "%\'"
    b.Groups.AddDef("原料名称") 
b.Totals.AddDef("设定值") 
b.Totals.AddDef("实际值") 
b.Totals.AddDef("误差值") 
b.Build \'生成统计表 
MainTable = Tables("统计表1")
         .Load()
    End With
End If

--  作者:有点蓝
--  发布时间:2020/2/22 11:38:00
--  
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

可以直接统计后台数据的
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
    Dim b As New SQLGroupTableBuilder("统计表1","生产记录")
    b.C \'改为自己数据源名称,如果不是外部表,去掉这句即可
    b.Groups.AddDef("原料名称")
    b.Totals.AddDef("设定值")
    b.Totals.AddDef("实际值")
    b.Totals.AddDef("误差值")
    b.Filter = "日期>=#" & d1 & "# and 日期<=#" & d2 & "# and 配方名称 like \'%" & s & "%\'"
    b.Build \'生成统计表
    MainTable = Tables("统计表1")
End If

--  作者:wujie
--  发布时间:2020/2/22 11:48:00
--  这个是在窗口按钮中实现的
运行了一下系统直接弹出去了
--  作者:有点蓝
--  发布时间:2020/2/22 13:16:00
--  
上面那段,还是下面那段?这种代码不应该会导致闪退的。一般是和其他事件冲突了,上传实例看看