反你的代碼帖出來,好象你的代碼有問題?下面我我調用的一段代碼Option ExplicitPrivate Sub Form_Load() Dim strPathName As String, strReportName As String, strSqlPath As String Dim rsPath As New ADODB.Recordset strSqlPath = "select mean from Parameter_tab where parameter_name='tabOrderFormReport'" rsPath.Open strSqlPath, strPubConnect, adOpenKeyset, adLockReadOnly If Not rsPath.EOF Then strPathName = rsPath.Fields(0).Value Else MsgBox "§ä¤£¨ì³øªí¸ô®|¡A½Ð»P¸ê°TÁp¨t¡I", vbCritical, "´£¿ô±z" Exit Sub End If strReportName = "custom_tabMaterialGoinReport.rpt"
End SubPrivate Sub Form_Resize() CRViewer91.Top = 0 CRViewer91.Left = 0 CRViewer91.Height = ScaleHeight CRViewer91.Width = ScaleWidth End Sub
改用10.0版本后,问题又变了: 执行到Form2.CRViewer91.ViewReport这里,程序报错“This field name is not known”。我检查过几个字段,都是对应的。这是什么问题呢? 以下是代码片段: Set Report = CryApp.OpenReport(App.Path & "\" + ReportFile) rs1.Open "select * from jincang_ordergoods where billnum in (select billnum from jincang_orders where storage " + SQL + ")", cnn rs2.Open "select billnum,storage from jincang_orders where storage " + SQL, cnn rs3.Open "select goodnum,amount from xiaoshou_ordergoods where billnum in (select billnum from jincang_orders where storage " + SQL + ")", cnn Report.Database.Tables(1).SetDataSource rs1 Report.Database.Tables(2).SetDataSource rs2 Report.Database.Tables(3).SetDataSource rs3 Report.DiscardSavedData Load Form2 Form2.CRViewer91.ReportSource = Report Form2.CRViewer91.Refresh
Dim strPathName As String, strReportName As String, strSqlPath As String
Dim rsPath As New ADODB.Recordset
strSqlPath = "select mean from Parameter_tab where parameter_name='tabOrderFormReport'"
rsPath.Open strSqlPath, strPubConnect, adOpenKeyset, adLockReadOnly
If Not rsPath.EOF Then
strPathName = rsPath.Fields(0).Value
Else
MsgBox "§ä¤£¨ì³øªí¸ô®|¡A½Ð»P¸ê°TÁp¨t¡I", vbCritical, "´£¿ô±z"
Exit Sub
End If
strReportName = "custom_tabMaterialGoinReport.rpt"
Screen.MousePointer = 11
Set objReport = objApp.OpenReport(strPathName & strReportName, 1)
' Set objReport = objApp.OpenReport("G:\Report\" & strReportName, 1)
objReport.Database.SetDataSource rsImport
objReport.ReadRecords
CRViewer91.ReportSource = objReport
CRViewer91.ViewReport
Screen.MousePointer = 0
End SubPrivate Sub Form_Resize()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidth
End Sub
执行到Form2.CRViewer91.ViewReport这里,程序报错“This field name is not known”。我检查过几个字段,都是对应的。这是什么问题呢?
以下是代码片段:
Set Report = CryApp.OpenReport(App.Path & "\" + ReportFile)
rs1.Open "select * from jincang_ordergoods where billnum in (select billnum from jincang_orders where storage " + SQL + ")", cnn
rs2.Open "select billnum,storage from jincang_orders where storage " + SQL, cnn
rs3.Open "select goodnum,amount from xiaoshou_ordergoods where billnum in (select billnum from jincang_orders where storage " + SQL + ")", cnn
Report.Database.Tables(1).SetDataSource rs1
Report.Database.Tables(2).SetDataSource rs2
Report.Database.Tables(3).SetDataSource rs3
Report.DiscardSavedData
Load Form2
Form2.CRViewer91.ReportSource = Report
Form2.CRViewer91.Refresh
Form2.CRViewer91.ViewReport'执行到这里出错
Form2.Show