[RESOLVED] Crystal Report viewing Plss. help
i created a common form that will be called by any form
within my project, i just change the value of global variables (gstrRptCmd, gstrRptPaperSize..etc)
actually, i was able to load the report, but it consumes a lot of memory, that's why when i call again the frmcrviewer.frm, the program exits.
im attaching the code i use.. pls. help...
thanks in advance
-- alexis :wave:
VB Code:
' FORM NAME = frmCRviewer.frm
Option Explicit
Dim crxApplication As CRAXDDRT.Application
Dim crxReport As CRAXDDRT.Report
Dim crxDatabase As CRAXDDRT.Database
Dim adoCReportRS As ADODB.Recordset
Dim dbx As ADODB.Connection
Private Sub Form_Load()
Me.Caption = gstrRptTitle
Set dbx = New ADODB.Connection
dbx.CursorLocation = adUseServer
dbx.Open gstrConnectString
Set adoCReportRS = New ADODB.Recordset
Set crxApplication = New CRAXDDRT.Application
Set crxReport = New CRAXDDRT.Report
Set crxDatabase = crxReport.Database
Call InitializeViewer
End Sub
Private Sub Form_Resize()
CRViewer1.Height = Me.ScaleHeight
CRViewer1.Width = Me.ScaleWidth
End Sub
Private Sub InitializeViewer()
On Error Resume Next
' gstrRptCmd is a global variable that containing the sql statement
adoCReportRS.Open gstrRptCmd, dbx, adOpenStatic, adLockReadOnly
Set crxReport = crxApplication.OpenReport(gstrRptPath, 1)
crxReport.DiscardSavedData
crxReport.Database.SetDataSource adoCReportRS , 3, 1
' global variable that holds the paper size and paper orientation
crxReport.PaperSize = gstrRptSize
crxReport.PaperOrientation = gstrRptOrientation
crxReport.Sections("PH").ReportObjects("CompanyName").SetText gstrCompanyName
crxReport.Sections("PH").ReportObjects("ReportTitle").SetText gstrRptTitle
crxReport.Sections("PH").ReportObjects("ReportSubTitle").SetText gstrRptSubTitle
CRViewer1.ReportSource = crxReport
CRViewer1.ViewReport
Do While crxReport.PrintingStatus.Progress = crPrintingInProgress
DoEvents
Loop
Set crxApplication = Nothing
Set crxDatabase = Nothing
Set crxReport = Nothing
End Sub
Re: Crystal Report viewing Plss. help
Welcome to the Forums.
I see two areas of concern, the CursorLocation being on the server side and the Do Loop with the DoEvents in it.
Shouldnt you be using the "crxReport.PrintOut True, 1" for Printing instead of PrintingStatus? Which version are you running?
Re: Crystal Report viewing Plss. help
im using crystal report v9.2
thanks, i'll try using the CursorLocation on the client side...
regards to you.
Re: Crystal Report viewing Plss. help
The other things was that this loop is sucking up resources with its intense looping.
VB Code:
Do While crxReport.PrintingStatus.Progress = crPrintingInProgress
DoEvents
Loop
Re: Crystal Report viewing Plss. help
i tried the adUseClient and get rid of the do events, but nothing was changed.. my application uses at 17mb of memory before the crystal report was called, then it rises up to around 40mb after i called the form containing this code.
can you post other way of viewing crystal report?? (if any),
thanks again.
alexis :p
Re: Crystal Report viewing Plss. help
Yes, I have an example in my signature. :)
Re: Crystal Report viewing Plss. help
how can i view it,.. im a newbie here...
aleixs
Re: Crystal Report viewing Plss. help
oh.. i saw it.. tks again.. i'll try the code.
alexis
Re: Crystal Report viewing Plss. help
your code was really a great help... the memory consumption didn't changed by it doesn't exits the program.
thank you very much...
Re: [RESOLVED] Crystal Report viewing Plss. help
It could also be sucking up memory from a large recordset being opened.
Thanks :)
Re: [RESOLVED] Crystal Report viewing Plss. help
what if it is really a large recordset? is there any solution? because im developing an inventory system, the records could take up a year or more.
alexis
Re: [RESOLVED] Crystal Report viewing Plss. help
Quote:
Originally Posted by alexis23
what if it is really a large recordset? is there any solution? because im developing an inventory system, the records could take up a year or more.
alexis
Why do you need to have all of your records in one recordset? Just bring back a recordset of what is needed at the time.
Re: [RESOLVED] Crystal Report viewing Plss. help
I have a client that runs a major MRP program that returns massive recordsets that produce CR reports that are over 1000 pages+ easy.
Re: [RESOLVED] Crystal Report viewing Plss. help
yup.. i know, but there are reports that should be printed their history like "stock movement report" or alike.
anyway, i have another post, i hope you could me for that matter too..
thanks
alexis