以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  怎么重复用2次代码才能查询到结果,有什么问题吗  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=146500)

--  作者:wujie
--  发布时间:2020/2/25 11:17:00
--  怎么重复用2次代码才能查询到结果,有什么问题吗
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

Dim d3 As Date = e.Form.Controls("H").Value
Dim d4 As Date = e.Form.Controls("I").Value
Dim s1 As String = e.Form.Controls("J").Value
   Dim c As New GroupTableBuilder("统计表1",DataTables("生产记录")) 
    c.Filter = "日期>=#" & d3 & "# and 日期<=#" & d4 & "# and 配方名称 like \'%" & s1 & "%\'"
    c.Groups.AddDef("配方名称")
    c.Totals.AddDef("设定值")
    c.Totals.AddDef("实际值")
    c.Totals.AddDef("误差值")
        c.Build \'生成统计表
    MainTable = Tables("统计表1")

Tables("主控窗口_Table2").DataSource = c.BuildDataSource()

--  作者:有点蓝
--  发布时间:2020/2/25 11:41:00
--  
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=146366&skin=0

如果搞不清楚,就上传实例

--  作者:wujie
--  发布时间:2020/2/25 11:51:00
--  麻烦看下里面第三章报表按钮的代码
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:学习.foxdb


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