Data room Charging System Report (2)

Source: Internet
Author: User
In the previous article, we talked about how to use the report designer to set a report template. Now we have implemented the report in vb. Before the report, we have loaded the parts in the previous article, after being referenced, two third-party controls, GRDisplayViewer and GRPrintViewer, are displayed in the control toolbox. Place GRDisplayViewer (REPORT query display) in the form

In the previous article, we talked about how to use the report designer to set a report template. Now we have implemented the report in vb. Before the report, we have loaded the parts in the previous article, after being referenced, two third-party controls, GRDisplayViewer and GRPrintViewer, are displayed in the control toolbox. Place GRDisplayViewer (REPORT query display) in the form

In the previous article, we talked about how to use the report designer to set a report template. Now we have implemented the report in vb. Before the report, we have loaded the parts in the previous article, after being referenced, two third-party controls, GRDisplayViewer and GRPrintViewer, are displayed in the control toolbox. Place the GRDisplayViewer (REPORT query display) on the form, and then use the code to import the template to implement the report.

My form layout is as follows:

There are three command buttons: refresh, print, and print preview. First, define

Dim WithEvents Report As grproLibCtl. GridppReport instantiation Report
WithEvents note: the event variable Report triggered by processing the time source is used to process the event of the object. You can specify the object type by providing the class name. This class is the class for creating this object. WithEvents variables cannot be derived Object variables, that is, they cannot be declared As objects-the class name must be specified when the variable is declared. The WithEvents variable cannot be declared As New. You must explicitly create an event source object and assign it to the WithEvents variable. The WithEvents variable cannot be declared in the standard module. It can only be declared in the class module, form module, and other definition class modules. You cannot create an array of WithEvents variables. Below is the code in the refresh button.
   GRDisplayViewer1.Refresh
Print the preview code
Report. [Print] (True) 'print. Because the print method name of the Report object conflicts with the internal definition method of vb, brackets are used.
The following is the code in the Form_Load () event.
Private Sub Form_Load () Dim strSQL As String, strMsg As String strSQL = "select * from checkday_info where date = '" & Format (Date, "yyyy-mm-dd ") & "'" Set Report = New grproLibCtl. gridppReport 'instantiate the template Report. loadFromFile (App. path & "\ checkday. grf ") 'Load the template Report. detailGrid. recordset. connectionString = ConnectString () 'Connection data source Report. detailGrid. recordset. querySQL = strsql' create record set GRDisplayViewer1.Report = report' by using SELECT query to grant the data to Report GRDisplayViewer1.Start 'of GRD to start printing End Sub
Third-party controls are referenced here again. It can be seen that vb programming is powerful. It is similar to the previous steps for exporting data from vb to Excel, as well as Recordset objects.
Dim xlsApp As Excel.ApplicationSet xlsApp = CreateObject("Excel.Application")
They are both defined first, assigned values, and finally used. We have never touched on these lines of code before. It is worth pondering.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.