When I was working on the data center charging system some time ago, the selected time period in the form added to the weekly statement report should be displayed in the report, which has not been clarified yet. I accidentally figured it out from some code today. It is mainly to dynamically Add a static text box in the form to display the required text. The code and main form interfaces are as follows for everyone to study and learn.
Option explicitdim report as grprolibctl. gridppreportprivate sub rshow () dim strsql as string dim strmsg as string strsql = "select * From checkweek_info where date <= '" & format (cbotimestart. text, "yyyy-mm-dd") & "'and date <='" & format (cbotimeend. text, "yyyy-mm-dd") & "'" Set Report = new grprolibctl. gridppreport. loadfromfile (App. path & "\ checkweek. GRF ") 'Load the template report. detailgrid. recordset. connectionstring = connstring 'data source report. detailgrid. recordset. querysql = strsql' create a record set through SELECT query '================= custom controls in reports ======== ======== dim reportheader as igrreportheader dim staticbox as igrstaticbox set reportheader = report. insertreportheader: Insert a static text box to display the text set staticbox = reportheader. controls. add (grctstaticbox ). asstaticbox staticbox. TEXT = cbotimestart. text & "to" & cbotimeend. text staticbox. width = 500 '========================================== ====================== grdisplayviewer1.report = Report grdisplayviewer1.startend subprivate sub cmdrefresh_click () grdisplayviewer1.refresh 'refresh end subprivate sub into view_click () report. printpreview (true) 'print and preview end subprivate sub into print_click () report. [print] (true) 'print end sub