因此,我在第一次尝试运行报告时遇到Crystal Reports问题,报告显示为空。报告显示了各种分隔符,行,框等,但没有填写报告的数据。我正在使用Visual Basic 6编码。我使用了大量的继承代码,处理实际Crystal Reports的代码是用于其他报告的文件,并且工作正常。所以我敢肯定,问题出在我所做的事情上,我搞乱了一些东西。VB6中的Crystal Reports在第一次运行时显示为空
这里是我到目前为止的代码:
Dim rs As ADODB.Recordset
Dim strRptFilePathTemp As String
Dim strRptFileName As String
Dim cSql As String
cSql = "SELECT * FROM TABLE1"
Set rs = DbConn.runStatement(cSql, "rs call", , , , , , , , , , True) 'gets a recordset based on the sql statement above
On Error GoTo ErrHandler
strRptFileName = "ReportName.rpt"
strRptFilePathTemp = App.Path
Screen.MousePointer = vbHourglass
Set frmcrystalreport.ReportRS = rs
DoEvents
frmcrystalreport.reportfile = strRptFilePathTemp & strRptFileName
frmcrystalreport.ReportTitle = _
frmCrystalReportsMainForm.GetRptTitle1("ReportTitle, ") & vbCrLf
gblStrReportFileNameLastRun = frmcrystalreport.reportfile
Screen.MousePointer = vbDefault
DoEvents
frmcrystalreport.Show vbModal
If Not frmcrystalreport.ReportRS Is Nothing Then
frmcrystalreport.ReportRS.Close
Set frmcrystalreport.ReportRS = Nothing
End If
Exit Sub
End If
End Sub
我已经试过玩弄的功能的DoEvents,看是否可以帮助,但还没有多少运气吧。在最初的失败尝试运行报告后,一切正常。只要我没有退出该程序,只要我通过该空白报告,就会打印出包含有效数据的报告。谢谢你们可以给我的任何帮助。