Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple reports should not print
Message
General information
Forum:
Crystal Reports
Category:
Data access
Environment versions
Crystal Reports:
Crystal Reports XI
Miscellaneous
Thread ID:
01371505
Message ID:
01371522
Views:
10
This message has been marked as the solution to the initial question of the thread.
Two things:
Make sure you are using Crystal XI, R2
and
sounds like the subreport is in the wrong band on the report.


>My problem is if there are more than 1 record, both reports prints for each record in the subreport. The 1st dataset is always 1 record, the 2nd dataset (subreport) can be from 1 to 1000 records. There must be a property that says print all data in 1 report and I cannot find it. Please look over the code and see if I can do something different. Thanks in advance.
>
>I have been playing with Crystal Reports for the first time. I have the code working to send a report to the printer, no preview. I have 2 reports using ADO recordset:
>1st report uses 1 dataset for header info
>2nd report uses the 1st report dataset for its header info and has an embedded 2nd(subreport) report using a different dataset. The code is below:
>
>IF .m_get_MemoData(psData,psGrpId)
>     *Handle the ADO stuff
>     oConn = CREATEOBJECT("ADODB.Connection")
>     oConn.ConnectionString = "Provider=VFPOLEDB.1;Data Source="+oApp.DbfPath+";Password=''"
>     oConn.Open()
>     oRs = CREATEOBJECT("ADODB.RecordSet")
>     oRs.Open("Select * FROM memoinfo", oConn)
>     IF OCCURS("pn",LOWER(psDoc))>0
>	oRs2 = CREATEOBJECT("ADODB.RecordSet")
>	oRs2.Open("Select * FROM memodata", oConn)
>     ENDIF && OCCURS("pn",LOWER(psDoc))>0
>     *create Crystal Reports object
>     oCR = CREATEOBJECT("CrystalRuntime.Application")
>     IF TYPE('oCR') <> 'O'
>	.p_Message = .p_Message+CHR(13)+'m_Vfp_To_Cr() COULD NOT ACCESS Crystal Reports Application object !'
>	llContinue = .F.
>     ELSE
>	*create the report object
>	oRpt = oCR.OpenReport(lsMemo_Location)
>	IF TYPE('oRpt') <> 'O'
>	     .p_Message = .p_Message+CHR(13)+'In m_Vfp_To_Cr(), '+ALLTRIM(psDoc)+' CRYSTAL REPORT report object NOT created !'
>	     llContinue = .F.
>	ELSE
>	     oRpt.Database.Tables.Item(1).SetDataSource(oRs)
>	     * if memoPn.rptmemosub.rpt, with the property numbers,
>	     * do not print, it will print with memopn.rpt
>	     IF OCCURS("pn",LOWER(psDoc))>0
>		oSub = oRpt.OpenSubreport("memosub.rpt")
>		IF TYPE('oSub') <> 'O'
>		     .p_Message = .p_Message+CHR(13)+'In m_Vfp_To_Cr(), '+ALLTRIM(psDoc)+' CRYSTAL REPORT report object NOT created !'
>		     llContinue = .F.
>		ELSE
>		     oSub.Database.Tables.Item(1).SetDataSource(oRs2)
>		ENDIF && TYPE('oSub') <> 'O'
>	     ENDIF && OCCURS("pn",LOWER(psDoc))>0
>	ENDIF && TYPE('oRpt') <> 'O'
>     ENDIF && TYPE('oCR') <> 'O'
>     * in case data was saved with the report, remove it
>     * so the correct data source will be used
>     IF oRpt.HasSavedData
>	oRpT.DiscardSavedData()
>     ENDIF
>     * open printer prompt to print
>     oRpt.PrintOut()
>     IF .p_Error > 0
>	llContinue = .F.
>     ENDIF && 
>* reset ole object to off to save overhead
>     oRs.Close
>     IF TYPE('oRs2')='O'
>	oRs2.Close
>     ENDIF && 
>     oConn.Close
>     oCr.CanClose
>     oSub = null
>     oRpt = null
>     oCr = null
>     RELEASE oCR,oRpt,oSub,oConn,oRs,oRs2
>     SET OLEOBJECT OFF
>ELSE 
>     *message provided in m_Get_MemoData()
>     llContinue = .F.
>ENDIF && .m_get_MemoData(pcGroupId)
>RETURN llContinue
>
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform