机房收费系统之报表总结2

 

在上一篇中已经说了如何构建报表模板,接下来就是用vb调用报表模板以此来实现报表的输出。下面是一些具体的过程:

 

’定义报表
Dim Report As grproLibCtl.GridppReport

Private Sub cmdPrint_Click()

‘打印报表

    Report.[Print] (True)

End Sub

 

Private Sub cmdPrintPreview_Click()

’打印预览

    Report.PrintPreview (True)

End Sub

Private Sub cmdRefresh_Click()

‘刷新报表

    txtSQL = "select * from daybill_Info where daydate='" & Format(Date, "yyyy-mm-dd") & "'"

    Report.DetailGrid.Recordset.QuerySQL = txtSQL

    GRDisplayViewer1.Refresh

End Sub

Private Sub Form_Load()

 '将日结账单以报表形式显示出来

    '建立查询语句

    txtSQL = "select * from daybill_Info where daydate='" & Format(Date, "yyyy-mm-dd") & "'"

    '创建报表对象

    Set Report = New grproLibCtl.GridppReport

    '载入报表模板文件

    Report.LoadFromFile (App.Path & "\报表\日结账单1.grf")

    '设置数据连接串

    Report.DetailGrid.Recordset.ConnectionString = ConnectionString()

    '载入查询语句

    Report.DetailGrid.Recordset.QuerySQL = txtSQL

    '显示报表中的内容

    GRDisplayViewer1.Report = Report

    GRDisplayViewer1.Start

End Sub

 

而在周结账单中只要引进参数即可:

'设置报表参数

    Report.ParameterByName("datestart").AsString = Str(startTime.Value)

    Report.ParameterByName("dateend").AsString = endTime.Value

 

你可能感兴趣的:(总结)