求vb打印预览控件源码程序

求vb打印预览控件源码程序,第1张

Private Sub Command1_Click()

Dim conn As New ADODB.Connection

Dim rs As New ADODB.Recordset

Dim oApp As New CRAXDRT.Application

Dim oRpt As CRAXDRT.Report

Dim reportName As String

Dim connstr As String

Dim sSQL As String

'上面三行是新察衡增败历做加的

Screen.MousePointer = vbHourglass

reportName = "\TOAAGLE001.rpt" '定义要引用的rpt文件

Set oRpt = oApp.OpenReport(App.Path &reportName, 1)

oRpt.Database.SetDataSource rs '连接水晶报表和数据源

oRpt.ReadRecords

CRViewer1.ReportSource = oRpt '启用水晶报表的预览功能

CRViewer1.ViewReport

Screen.MousePointer = vbDefault

If conn.State = adStateOpen Then conn.Close

'connstr = "Provider=MicroSoft.Jet.OLEDB.4.0Data Source=" &App.Path &"\prtest.mdbPersist Security Info=False" 'prtest.mdb是程序当前目录的测试Access数据库

connstr = "烂昌Provider=MSDASQL.1Extended Properties='DRIVER=sql serverSERVER=OC_CHINA05UID=HXMFGPWD=perfect888APP=Visual BasicWSID=PC-201104151518DATABASE=Taileec6'"

conn.ConnectionString = connstr

conn.Open

conn.CursorLocation = adUseClient

If rs.State = adStateOpen Then rs.Close

If Trim(txtno.Text &"") = "" Then

sSQL = "SELECT * FROM dbo.INM_SYS_SYSPARAMETER RIGHT OUTER JOIN dbo.T_AGLE_M ON dbo.INM_SYS_SYSPARAMETER.SYS_PAR_CODE_C = dbo.T_AGLE_M.huopindanwei LEFT Outer Join dbo.INM_ITEM_M ON dbo.T_AGLE_M.huopinid = dbo.INM_ITEM_M.ITM_M_ITEMNO_C RIGHT OUTER JOIN dbo.T_AGLE_D LEFT OUTER JOIN dbo.INM_CUST_M ON dbo.T_AGLE_D.kehuid = dbo.INM_CUST_M.CUST_M_CUSTNO_C ON dbo.T_AGLE_M.dingdanid = dbo.T_AGLE_D.dingdanid"

Else

sSQL = "SELECT * FROM dbo.INM_SYS_SYSPARAMETER RIGHT OUTER JOIN dbo.T_AGLE_M ON dbo.INM_SYS_SYSPARAMETER.SYS_PAR_CODE_C = dbo.T_AGLE_M.huopindanwei LEFT Outer Join dbo.INM_ITEM_M ON dbo.T_AGLE_M.huopinid = dbo.INM_ITEM_M.ITM_M_ITEMNO_C RIGHT OUTER JOIN dbo.T_AGLE_D LEFT OUTER JOIN dbo.INM_CUST_M ON dbo.T_AGLE_D.kehuid = dbo.INM_CUST_M.CUST_M_CUSTNO_C ON dbo.T_AGLE_M.dingdanid = dbo.T_AGLE_D.dingdanid Where dbo.T_AGLE_D.dingdanid='" &Trim(txtno.Text &"") &"'"

End If

rs.Open sSQL, conn, adOpenKeyset, adLockReadOnly

'CRViewer1.ReportfileName = App.Path &"\TOAAGLE001.rpt"

'CRViewer1.PrintReport

End Sub

VB下数据报表打印输出方法有多种,一是通过自己的设肢答计和编程完成报表打印输出。二是通过MS OFFICE实现报表打印输出历棚慧。三是应用数据和渣报表设计器的报表打印输出。本人经常使用第一种方法,它具有根据需要灵活应用的特点,但需编写程序。

代码见:

http://iask.sina.com.cn/b/2350257.html

本人的答复。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12367379.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存