Data room Charging System (III)-VB and report

Source: Internet
Author: User
Tags odbc connection


Weekly reports made me struggle for several days. Today I did a little bit and found that I could not do it, so I stayed for the next day. In this way, a report left me suspended for about four or five days.

Table creation:

1: Click Insert. Select Report header, report end, header, and detail grid respectively"

2: click "insert" -- select "static box" and add text information to the static box.

3: click "insert"-select "text box" and set the parameters "startdata" and "enddata" in the text box"

That is, enddata is the same as startdata.


4: click "SQL" to complete database connection


After you click "test", the following form may appear:


This error occurs when the report is connected to the database. The solution is:

First, use the SA authentication, Windows authentication, oledb connection to the database, and ODBC connection to the database;

Second, the database connection statement in the database connection module.

5: click "CLM (automatically generate columns Based on fields)" to complete column setting.


6. Double-click the field in the title line to complete the settings for the title line.


In this way, the establishment of the report is complete, and the rest, that is, the connection between VB and the report, in VB, the report display problem.

Report interaction with VB1: interface:
2: Add a part and instantiate the report
Dim withevents report as grprolibctl. gridppreport instantiation report

Withevents Note: Process events caused by time sources

The variable report is used to process object events. 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 to say, you cannot declare it as an as object. When declaring this variable, you must specify the class name. You cannot declare the withevents variable as new. The event source object must be explicitly created and assigned to the withevents variable. The withevents variable cannot be declared in the standard module. The withevents variable array cannot be created only in the module of the class module, form module, and other definition classes.
3: loading the Write Program form in VB:
Private sub form_load () 'create a report object set report = new grprolibctl. gridppreport' load the report template file report. loadfromfile (App. path & "\ weekly report. GRF ") 'sets the data connection string report. detailgrid. recordset. connectionstring = "provider = sqloledb; server = zhudan-PC; database = charge1_sys; Integrated Security = sspi" 'is used to make the grdweekliybill report queryer control display the content in the report grdweekliybill. report = Report grdweekliybill. start Report. parameterbyname ("startdate "). value = format $ (startdateview. value, "yyyy-mm-dd") report. parameterbyname ("enddate "). value = format $ (enddateview. value, "yyyy-mm-dd") 'date control is invisible to startdateview. visible = false enddateview. visible = falseend sub

Refresh:

Private sub cmdrefresh_click () 'bill refresh dim strsql as string dim strmsg as string dim objrsweekliybill as ADODB. recordset dim objrsdaliybill as ADODB. recordset if startdateview. value> enddateview. value then' condition restriction msgbox "the end date cannot be earlier than the start date! ", Vbokonly + vbexclamation," warning "Exit sub end if 'selected strsql =" select * From daycheckinfo where date between' "& format $ (startdateview. value, "yyyy-mm-dd") & "'" & "and'" & format $ (enddateview. value, "yyyy-mm-dd") & "'" set objrsdaliybill = executesql (strsql, strmsg) strsql = "select * From weekcheckinfo" set objrsweekliybill = executesql (strsql, strmsg) do While objrsweekliybill. EOF = false objrsweekliybill. delete objrsweekliybill. movenext loop 'is updated to do while objrsdaliybill. EOF = false' checks whether data exists with objrsweekliybill. addnew. fields (0) = objrsdaliybill. fields (0 ). fields (1) = objrsdaliybill. fields (1 ). fields (2) = objrsdaliybill. fields (2 ). fields (3) = objrsdaliybill. fields (3 ). fields (5) = objrsdaliybill. fields (4 ). fields (4) = objrsdaliybill. fields (5 ). update objrsdaliybill. movenext end with loop grdweekliybill. refresh 'refresh the report. detailgrid. recordset. querysql = "select * From weekcheckinfo where date between '" & startdateview. value & "'and'" & enddateview. value &"'"

The reason why my reports do not search for data in a certain date according to my "requirements" is that the last sentence is missing.
4: displays the result at most.
Learning makes me Tangle and depressed in this process. But when I understand and understand it, there is a burst of sunshine. For that ray of sunshine, we continue to work hard, in pursuit ~~~~~~~~


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.