Crystal Report is the most professional and functional Report System in the industry. In addition to powerful report functions, crystal report has achieved integration and interfaces with most popular development tools. Programmers who have worked in report development on vs. NET platform must have been impressed by the powerful, efficient, and integrated features of Crystal Reports. In addition to developing new programs, we often need to meet the needs of many early software system report function upgrades. If we can combine the powerful tool of Crystal Report, we can always get twice the result with half the effort. VB is a popular database development platform in the past. Its C/S system has a huge social inventory, however, over-weak reporting functions of VB often make programmers unable to cope with customers' upgrade requirements. This article does not do the use of the Crystal Report and programming teaching, in fact, the use of the crystal report itself and. NET platform is not much different. I mainly discuss with you a more convenient interface method of VB and Crystal Reports. My development and testing platform is Windows 9.0 standard Simplified Chinese version, VB6.0 SP5 English version, and crystal Simplified Chinese development version. The method for making a report template in the crystal report is not the scope of this article. You can refer to the Help file of the Crystal Report and the technical materials on the official website. To put it simply, you must first manually connect to the corresponding table structure through the database engine of the Crystal Report, create a report template, and save it as a rpt file. This operation is similar to using the report tool that comes with VB to create a report. To put it simply, the simple method of calling the Crystal Report for report development using VB is to use "field definition only" in the crystal report to obtain the field distribution file and create a table field using a virtual file, use the craxdrt object to forcibly change the data source (ADO. recordset). The effect is equivalent to calling the rpt file in VB. The following describes the programming method in steps. Step 1: Add "add crystal report 9" to the project menu of the VB project. Use the default report name. In this case, form2 (the form automatically added by crystal rerport, assuming the name is form2) is automatically assigned the following code: Option explicitdim report as new cystal1private sub form_load () screen. mousepointer = vbhourglass 'when you call the crystal report, set the mouse to an hourglass-like crviewer91.reportsource = Report'. The value assignment of this statement will be changed to crviewer91.viewreport screen later. mousepointer = vbdefault 'Call the Crystal Report to complete the post-mouse for the default shape end subprivate sub form_resize () crviewer91.top = 0 crviewer91.left = 0 crviewer91.height = scaleheight crviewer9 1. width = scalewidthend sub Step 2: click "database Field" in the crystal report designer and select "database expert... ", Click" Create New Connection ", and then click" field definition only "to create a" database definition "file. The field name and width are consistent with those of the original database table. Finally, the corresponding fields are obtained in the database field, placed on the report, and configured according to the requirements of the crystal report. Step 3: This step is critical. Add a modual to the project file and define the global ADODB variable to achieve dynamic connection between the database and the crystal report. The Code is as follows: public conn as new ADODB. connectionpublic RS as new ADODB. recordset Step 4: For considerations about connecting to the ADO database of vbprogram, see the following print button routine. Private sub commandateclick () dim connstr as string if Conn. state = adstateopen then Conn. close connstr = "provider = Microsoft. jet. oledb.4.0; Data Source = "& App. path & "/prtest. MDB; persist Security info = false "'prtest. MDB is the Test Access Database Conn in the current directory of the program. connectionstring = connstr Conn. open Conn. cursorlocation = aduseclient if RS. state = adstateopen then Rs. close Rs. open "test", Conn, adopenkeyset, adlockread Only 'report. database. after the setdatasource RS, 3, 1 form2.show 1 'database connection is complete, you must note that the report in the code above is called by the form2 crystal report project end sub. database. setdatasource RS, 3, 1 is an easy mistake for programmers who first use Crystal Reports. Using this statement will cause connection failure between the database and Crystal Reports. How to dynamically call the crystal report? See step 4. Step 5: create a connection between the Crystal Report and the database data source. You need to modify the form2 code above. Option explicit 'dim report as new cystal1' the above line cancels private sub form_load () dim oapp as new craxdrt. application dim orpt as craxdrt. the preceding three rows of report dim reportname as string are newly added screens. mousepointer = vbhourglass reportname = "/Rpt/pr1.rpt" 'defines the rpt file set orpt = oapp to be referenced. openreport (App. path & reportname, 1) orpt. database. setdatasource Rs 'connect to the crystal report and data source orpt. readrecords crviewer91.reportsource = orpt 'enable preview of the Crystal Report Crviewer91.viewreport screen. mousepointer = vbdefaultend subprivate sub form_resize () crviewer91.top = 0 crviewer91.left = 0 crviewer91.height = scaleheight crviewer91.width = scalewidthend subprivate sub form_unload (cancel as integer) 'set report = nothing set rs = nothing set conn = nothing unload form2end sub the above describes a method for developing reports using Crystal Reports in VB. This method is easy to use, suitable for beginners. After you are familiar with it, you can continue to learn the API functions provided by crystal report (LIB library crpe32.dll) for the development of Crystal Reports, which gives you more flexibility.