Results 1 to 14 of 14

Thread: [RESOLVED] Crystal Report viewing Plss. help

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Posts
    208

    Resolved [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


    VB Code:
    1. ' FORM NAME = frmCRviewer.frm
    2. Option Explicit
    3. Dim crxApplication As CRAXDDRT.Application
    4. Dim crxReport As CRAXDDRT.Report
    5. Dim crxDatabase As CRAXDDRT.Database
    6. Dim adoCReportRS As ADODB.Recordset
    7. Dim dbx As ADODB.Connection
    8.  
    9. Private Sub Form_Load()
    10.  
    11.     Me.Caption = gstrRptTitle
    12.     Set dbx = New ADODB.Connection
    13.     dbx.CursorLocation = adUseServer
    14.     dbx.Open gstrConnectString
    15.     Set adoCReportRS = New ADODB.Recordset
    16.    
    17.     Set crxApplication = New CRAXDDRT.Application
    18.     Set crxReport = New CRAXDDRT.Report
    19.     Set crxDatabase = crxReport.Database
    20.    
    21.     Call InitializeViewer
    22.  
    23. End Sub
    24.  
    25. Private Sub Form_Resize()
    26.     CRViewer1.Height = Me.ScaleHeight
    27.     CRViewer1.Width = Me.ScaleWidth
    28. End Sub
    29.  
    30. Private Sub InitializeViewer()
    31.    
    32.     On Error Resume Next
    33.     ' gstrRptCmd is a global variable that containing the sql statement
    34.     adoCReportRS.Open gstrRptCmd, dbx, adOpenStatic, adLockReadOnly  
    35.     Set crxReport = crxApplication.OpenReport(gstrRptPath, 1)
    36.     crxReport.DiscardSavedData
    37.    
    38.     crxReport.Database.SetDataSource adoCReportRS , 3, 1
    39.     ' global variable that holds the paper size and paper orientation
    40.     crxReport.PaperSize = gstrRptSize          
    41.     crxReport.PaperOrientation = gstrRptOrientation
    42.    
    43.     crxReport.Sections("PH").ReportObjects("CompanyName").SetText gstrCompanyName
    44.     crxReport.Sections("PH").ReportObjects("ReportTitle").SetText gstrRptTitle
    45.     crxReport.Sections("PH").ReportObjects("ReportSubTitle").SetText gstrRptSubTitle
    46.    
    47.     CRViewer1.ReportSource = crxReport
    48.     CRViewer1.ViewReport
    49.     Do While crxReport.PrintingStatus.Progress = crPrintingInProgress
    50.         DoEvents
    51.     Loop
    52.     Set crxApplication = Nothing
    53.     Set crxDatabase = Nothing
    54.     Set crxReport = Nothing
    55.  
    56. End Sub
    Last edited by RobDog888; Feb 27th, 2006 at 02:15 AM. Reason: Added [vbcode] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width