The method of dynamically loading Crystal Report rpt file in VB

Source: Internet
Author: User
Tags format
Dynamic | loading | Crystal Report This question is asked in many forums. But no satisfactory answer has been found. Write a solution below
Dim SQL as String
Dim Rstliushui as New ADODB. Recordset
Dim Rpt as New craxddrt. The
Dim Printapp as New craxddrt. Application
If Option2.value = True Then
sql = "SELECT * from N_ihbill where DateDiff (d, Date, '" & Format (Dtpicker1.value, "Yyyy-mm-dd") & "') =0 and inpatient number =" &am P Cbopatient. ItemData (cbopatient. ListIndex)
Else
sql = "SELECT * from N_ihbill where DateDiff (d, Date, '" & Format (Dtpicker1.value, "Yyyy-mm-dd") & "') =0"
End If
Debug.Print SQL

Rstliushui.open sql, Adoconn, adopenforwardonly, adLockReadOnly

If rstliushui.eof and Rstliushui.bof Then
MsgBox "No data available!" ", vbinformation
Exit Sub
End If

Set Rpt = Printapp.openreport ("Cryliushui.rpt")
Rpt.Database.SetDataSource Rstliushui

Call Viewreport (Rpt, "", "Print Water")
Rstliushui.close
Set Rstliushui = Nothing
This enables the logical separation of the program from the report. If you use Report Designer. You need to compile the program every time you change the report format. Customers can even change the report format themselves.




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.