In the data room charging system, the "weekly bill" function displays the corresponding bill data based on the selected time range. Then, the "parameter" setting is used.
First, insert the parameter in "report main object": Right-click "parameter set" -- insert -- parameter (DateBegin and DateEnd)
Then, insert the integrated text box -- insert -- Part Box -- integrated text box in the report template, and click the text box to enter the parameter name and displayed text in the format of [# Parameter1 #]. (set the time display format ):
First, add the component Grid ++ Report Engine5.0 Type Libirary to VB.
In VB, set the corresponding code:
'Define the variable with the corresponding event Dim WithEvents Report As grproLibCtl. gridppReportPrivate Sub Form_Load () 'create a Report object GRDisplayViewer1.Stop Set Report = New grproLibCtl. gridppReport: load the Report template file to ensure the relative path is Report. loadFromFile (App. path + "ChargeCheckDay. grf ")
'Set the database connection string Report. detailGrid. recordset. connectionString = "Provider = SQLOLEDB; Data Source = 192.168.24.54; Initial CataLog = Charge_zlj; UID = sa; PWD = 123456" 'displays the latest Report record in daily checkout. detailGrid. recordset. querySQL = "select top 1 * from CheckDay order by Date desc" 'sets the Report object GRDisplayViewer1.Report = report' for the Report query display control to run GRDisplayViewer1.Start End SubPrivate Sub Report_Initialize () 'set the parameter value' start time Report. parameterByName ("DateBegin "). asString = Format $ (DTPBegin. value, "yyyy-mm-dd") 'show start date' End Time Report. parameterByName ("DateEnd "). asString = Format $ (DTPEnd. value, "yyyy-mm-dd") 'display End date End SubPrivate Sub partition print_click () 'Print' because the Print method name of the report object conflicts with the internal definition of VB, therefore, enclose the Report in brackets. [Print] (True) End SubPrivate Sub partition printprevius_click () 'Print preview Report. printPreview (True) End Sub
Effect: