真正不受数据源限制的方法
Public RS As ADODB.Recordset
Private Sub DH_Change()
Dim oApp As New CRAXDRT.Application
Dim oRpt As CRAXDRT.Report
Dim reportName As String
Dim SQL$, I%, JEHJ$
Dim RS2 As ADODB.Recordset
SQL = "SELECT * FROM NBDBD_BT WHERE DBDH='" + Trim(DH.Text) + "'"
Set RS2 = CN.Execute(SQL)
JEHJ = "" & RS2("JEHJ")
If Val(JEHJ) = 0 Then JEHJ = "0"
SQL = "SELECT * FROM NBDBD_MX WHERE DBDH='" + Trim(DH.Text) + "'"
Set RS = New ADODB.Recordset
RS.Open SQL, CN, 1, 3
Screen.MousePointer = vbHourglass
reportName = App.Path + ""Reports"销售发货单.rpt" '定义要引用的rpt文件
Set oRpt = oApp.OpenReport(reportName, 1)
' oRpt.PaperSize = crPaperUser
' oRpt.SetUserPaperSize 1100, 2200 '自定义纸张大小 单位: 0.01mm
For I = 1 To oRpt.Database.Tables.Count
oRpt.Database.Tables(I).ConnectionProperties.DeleteAll
oRpt.Database.Tables(I).SetDataSource RS
Next I
CRViewer91.ReportSource = oRpt '启用水晶报表的预览功能
oRpt.DWMC.SetText Report_Name
oRpt.Text6.SetText "内部调拨发货单"
oRpt.XSDH.SetText "No:" + DH.Text
oRpt.RQ.SetText "日期:" & RS2("RQ")
oRpt.SHDZ.SetText "" & RS2("SHDZ")
oRpt.KHMC.SetText "" & RS2("KHMC")
oRpt.JEDX.SetText "(大写)" + ChMoney(JEHJ)
oRpt.CKMC.SetText "" & RS2("CKMC")
oRpt.THFX.SetText "" & RS2("THFX")
oRpt.CPHMc.SetText "" & RS2("CPHM")
oRpt.THR.SetText "" & RS2("THRXM")
oRpt.JSZT.SetText ""
oRpt.BZ.SetText "" & RS2("BZ")
oRpt.JJY.SetText "" & RS2("JJYXM")
oRpt.YXY.SetText "" & RS2("YXYXM")
oRpt.CGY.SetText "" & RS2("CGYXM")
oRpt.SHR.SetText "" & RS2("SHRXM")
oRpt.FHR.SetText "" & RS2("FHRXM")
oRpt.CZY.SetText "" & RS2("KDRXM")
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
Me.Width = 13140
RS2.Close
Set RS2 = Nothing
End Sub
Private Sub Form_DblClick()
Debug.Print Me.Width & "," & Me.Height
End Sub
Private Sub Form_Resize()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidth
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
RS.Close
Set RS = Nothing
End Sub
=============== 注意以下几行是清除水晶报表原来的所有边接
For I = 1 To oRpt.Database.Tables.Count
oRpt.Database.Tables(I).ConnectionProperties.DeleteAll
oRpt.Database.Tables(I).SetDataSource RS
Next I
回复
引用
查看