发表于:2008-07-07 23:12:36
楼主
Option Explicit
Rem 在水晶报表中用"仅字段定义"来获得字段分布文件
Rem 在窗体中插入一个CRViewer1控件和一个按钮控件
Rem 必须引用Crystal Reports 8.5 ActiveX Designer Run Time Library
Rem 在VB中下面的代码可用,但在IFIX-VBA中就无法运行,哪位高手指点一下这是为什么样
Private Sub Command1_Click()
Dim connstr As String
Dim oApp As New CRAXDRT.Application
Dim oRpt As CRAXDRT.Report
Dim reportName As String
If conn.State = adStateOpen Then conn.Close
connstr = "rovider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\HZZ_20\桌面\Northwind.mdb;Mode=ReadWrite|Share Deny Noneersist Security Info=False"
conn.ConnectionString = connstr
conn.Open
conn.CursorLocation = adUseClient
If rs.State = adStateOpen Then rs.Close
rs.Open "SELECT 客户ID,雇员ID,订购日期,到货日期,运货费,货主城市 from 订单", conn, adOpenDynamic, adLockBatchOptimistic
Screen.MousePointer = vbHourglass
reportName = "\Com_Report.rpt" '定义要引用的rpt文件,IFIX中改为"\APP\Com_Report.rpt"
Set oRpt = oApp.OpenReport(App.Path & reportName, 1)'IFIX中改为(System.FixPath & reportName, 1)
oRpt.Database.SetDataSource rs '连接水晶报表和数据源
oRpt.ReadRecords
CRViewer1.ReportSource = oRpt '启用水晶报表的预览功能
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
Set rs = Nothing
Set conn = Nothing
Set oApp = Nothing
Set oRpt = Nothing
End Sub
在IFIX中显视的错误
运行时错误'-2147206460(80043ac4)
Invalid directory