从vb6启动Crystal Report(+ subreport)

2020-09-04 13:02发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


如何使用vb6中的6个子报表启动Crystal报表。

我能够从Crystal报表文件中成功运行主报表,但是在vb6应用程序中引发了错误

错误表示参数也未馈入子报表。如何解决此问题?

但是,如果我只有一个子报表,则该应用程序可以正常运行。

出什么问题了?

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


如何使用vb6中的6个子报表启动Crystal报表。

我能够从Crystal报表文件中成功运行主报表,但是在vb6应用程序中引发了错误

错误表示参数也未馈入子报表。如何解决此问题?

但是,如果我只有一个子报表,则该应用程序可以正常运行。

出什么问题了?

付费偷看设置
发送
9条回答
SAP小菜
1楼-- · 2020-09-04 13:48

这是我的代码。谢谢!

Sub runReport()Dim crpPara如CRAXDRT.ParameterFieldDefinitions Dim crpPar如CRAXDRT.ParameterFieldDefinition Dim crxApp如新CRAXDRT.Application Dim crxDBField如CRAXDRT.DatabaseFieldDefinition Dim报告如新CRAXDRT.Report GetReportPath设置报告= grdApp.OpenReport(strReportPath)调用 SetDSN(Report,strDSN,strUserid,strPassword,strDatabase,AAAZ)使用crpPar Debug.Print .ParameterFieldName Select Case设置crpPara中每个crpPar的crpPara = Report.ParameterFields .ParameterFieldName Case" @lngGroupBy" Case" @lngGroup" Case" @strFilter " .SetCurrentValue Field2str(strFilter)案例" @strCodeType"案例" @strCaption" .SetCurrentValue Field2str(Me.Caption)案例" @Date" Dim strDate作为字符串.SetCurrentValue Field2str(strDate)案例" @ Date1" .SetCurrentValue Field2Date(Date )案例" @ Date2" .SetCurrentValue Field2Date(Date)案例" @dSBDate"案例" @ReportFilterCluster" .SetCurrentValue Field2str("")案例" @ strFilter0" .SetCurrentValue Field2str(m_strFilter0)案例" @ strFilter1" .S etCurrentValue Field2str(m_strFilter1)案例" @ strFilter2" .SetCurrentValue Field2str(m_strFilter2)案例" @strMassFilter"案例" @ strFilter3" .SetCurrentValue Field2str(m_strFilter3)案例" @ strFilter4" .SetCurrentValue Field2str(m_strFilter4)案例" @ strFilter5" .SetCurrentValue Field2str(m_strFilter5)案例" @ strFilter6" .SetCurrentValue Field2str(m_strFilter6)案例" @ strFilter7" .SetCurrentValue Field2str(m_strFilter7)案例" @ strFilter8" .SetCurrentValue Field2str(m_strFilter8)案例" @ strFilter9" .SetCurrentValue Field2str(m_strFilter9)案例" @ strFilter10" .SetCurrentValue Field2str(m_strFilter10)案例" @ strFilter11" .SetCurrentValue Field2str(m_strFilter11)案例" @strCode" .SetCurrentValue Field2str(strCode)案例" @lngGroup" .SetCurrentValue Field2Long(lngGroup)案例" @dDate" .SetCurrentValue Field2Date (日期)案例" @gstrITSfromHTD" .SetCurrentValue" HTD解决方案"案例" @Credit" .SetCurrentValue GetXMLName(" credit")案例" @Credit" .SetCurrentValue GetXMLType(" Credit")结束选择结束机智 h下一步设置crpPara =不使用CRViewer91 .ReportSource =报告'cryReport .ViewReport'.Zoom IIf(m_lngReportSize = 0,IIf(lngRepSize = 0,100,lngRepSize),m_lngReportSize)以

结尾

结束字幕

公共Sub DSN(作为报表的SourceReport,作为字符串的ByVal NewDSN,作为字符串的_ ByVal NewUserID,作为字符串的_ ByVal NewUserID,作为字符串的_ ByVal NewDatabase,作为字符串的ByVal NewServer)Dim strPath作为字符串Dim strODBC作为字符串Dim strDriverPath作为字符串 Dim strDriverName作为字符串出现在本地错误上GoIn errH Dim HK只要WinVersion =" Windows XP",则HK = -2147483646'WIN XP Else HK = -2147483647'WIN VISTA End如果strPath =" SOFTWARE \ ODBC \ ODBC.INI \" &NewDatabase&" \" strODBC =" SOFTWARE \ ODBC \ ODBC.ODBC.INI \ ODBC数据源\" Dim crpPara如CRAXDRT.ParameterFieldDefinitions Dim crpPar如CRAXDRT.ParameterFieldDefinition Dim crxApp如新CRAXDRT.Application Dim crxDBTField如CRAXDRT.DatabaseFieldDefinition Dim crxDBT如 CRAXDRT.DatabaseTable Dim crxDB作为CRAXDRT.DatabaseTable Dim crxDBTs作为CRAXDDRT.DatabaseTables设置crpPara = SourceReport.ParameterFields SourceReport.DiscardSavedData SourceReport.EnableParameterPrompting = False对于SourceReport.Database.Tables中的每个crxDB crxDB.Co nnectionProperties.DeleteAll crxDB.SetLogOnInfo NewDSN,NewDatabase,NewUserID,NewPassword'MsgBox Left(crxDB.Location,Len(crxDB.Location)-2)crxDB.Location = Left(crxDB.Location,Len(crxDB.Location)-2)下一页 退出子错误:MsgBox错误描述&""和err.Number,vbInformation,"错误"恢复下一个退出子

End Sub

SKY徐
2楼-- · 2020-09-04 13:45

嗨,Reuben,

子报表嵌入到主报表中,因此它不需要RPT文件的路径。 只是SubReport名称。 所以应该是这样:

设置crSubReport = crReport.OpenSubreport(" rptdiag1")

布莱恩

Tong__Ming
3楼-- · 2020-09-04 13:55

嗨,布莱恩

请先浏览该网站,然后再在此处发布。 无法理解该代码。再次查看。

也许您可以帮助我理解代码:

Sub LoadRptMultiSub

(Rpt作为字符串,sql作为字符串,autoprint作为布尔,SubSql()作为字符串,SubReportName()作为字符串,PV()作为字符串,PC作为Long,SubNum作为整数)

您了解变量吗:SubSql()作为字符串,SubReportName()作为字符串,

PC,PV,SubNum等?

除此之外,我得到了什么,但没有得到变量/参数???。谢谢

一周热门 更多>