PDA

Click to See Complete Forum and Search --> : [RESOLVED] Crystal Report viewing Plss. help


alexis23
Feb 27th, 2006, 01:10 AM
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:


' 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

RobDog888
Feb 27th, 2006, 01:15 AM
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?

alexis23
Feb 27th, 2006, 01:40 AM
im using crystal report v9.2

thanks, i'll try using the CursorLocation on the client side...

regards to you.

RobDog888
Feb 27th, 2006, 01:43 AM
The other things was that this loop is sucking up resources with its intense looping.
Do While crxReport.PrintingStatus.Progress = crPrintingInProgress
DoEvents
Loop

alexis23
Feb 27th, 2006, 02:52 AM
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

RobDog888
Feb 27th, 2006, 02:59 AM
Yes, I have an example in my signature. :)

alexis23
Feb 27th, 2006, 03:05 AM
how can i view it,.. im a newbie here...

aleixs

alexis23
Feb 27th, 2006, 03:06 AM
oh.. i saw it.. tks again.. i'll try the code.

alexis

alexis23
Feb 27th, 2006, 03:44 AM
your code was really a great help... the memory consumption didn't changed by it doesn't exits the program.

thank you very much...

RobDog888
Feb 27th, 2006, 04:00 AM
It could also be sucking up memory from a large recordset being opened.

Thanks :)

alexis23
Feb 27th, 2006, 04:52 AM
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

Hack
Feb 27th, 2006, 06:04 AM
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.

alexisWhy do you need to have all of your records in one recordset? Just bring back a recordset of what is needed at the time.

RobDog888
Feb 27th, 2006, 09:32 AM
I have a client that runs a major MRP program that returns massive recordsets that produce CR reports that are over 1000 pages+ easy.

alexis23
Feb 27th, 2006, 06:32 PM
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