Results 1 to 12 of 12

Thread: How can I view and take printout of crystal report?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    How can I view and take printout of crystal report?

    Hi,

    How can I view and take printout of the report which I have created in Crystal Reports 11? Please let me know the code for command buttons.

    Report1 >>>> is the report name >>>> using access database.

    Regards.

    Seema_s

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: How can I view and take printout of crystal report?

    Quote Originally Posted by seema_s
    Hi,

    How can I view and take printout of the report which I have created in Crystal Reports 11? Please let me know the code for command buttons.

    Report1 >>>> is the report name >>>> using access database.

    Regards.

    Seema_s
    Could somebody let me know the basic sample code to print a report?

    Regards.

    Seema_s

  3. #3
    New Member
    Join Date
    May 2006
    Posts
    2

    Re: How can I view and take printout of crystal report?

    hello,

    here is the result of the research I did yesterday, having the same question as you.

    It is in VB6, using Crystal Report XI. My project has 2 forms :
    Form1 contains the cmdButton command2
    Form2 contains the CrystalReport Viewer

    On click on Command2, the CRviewer is launched ...

    Here is my code : hope it will help you to begin ...

    VB Code:
    1. Private Sub Command2_Click()
    2.  
    3. Dim CrAppl As New CRAXDRT.Application
    4. Dim CrRep As New CRAXDRT.Report
    5.  
    6.         Set CrRep = CrAppl.OpenReport("C:\...\XXX.rpt")
    7.         With CrRep
    8.           'Selection
    9.           .RecordSelectionFormula = "{table.field} = 'value'"
    10.          
    11.           'Parameters
    12.           .ParameterFields.Item(1).AddCurrentValue "Title"
    13.           .ParameterFields.Item(2).AddCurrentValue "NoDate"
    14.          
    15.           'Order (on the field 'fieldname' from the 1st table on the report
    16.           Call .RecordSortFields.Add(.Database.Tables(1).Fields.GetItemByName("fieldname"), crAscendingOrder)
    17.            
    18.         End With
    19.        
    20.         'To view with the viewer        
    21.         Screen.MousePointer = vbHourglass
    22.         Form2.CRViewer1.ReportSource = CrRep
    23.         Form2.CRViewer1.ViewReport
    24.         DoEvents
    25.         Screen.MousePointer = vbDefault
    26.         Form2.Show
    27.  
    28.         'To Print without viewing the report
    29.         Form2.CRViewer1.ViewReport
    30.         DoEvents
    31.         Screen.MousePointer = vbDefault
    32.         Form2.CRViewer1.PrintReport
    33.        
    34.     'Full screen
    35.     Form2.Top = 0
    36.     Form2.Left = 0
    37.     Form2.Width = Screen.Width
    38.     Form2.Height = Screen.Height - 400
    39.     Form2.CRViewer1.Top = 0
    40.     Form2.CRViewer1.Left = 0
    41.     Form2.CRViewer1.Width = Form2.Width
    42.     Form2.CRViewer1.Height = Form2.Height
    43. End Sub

    My problem is now to print directly, whitout using the viewer, but with userPrompting for the printer selection. It seems that we need to use the PrintOut method (applied to the CrRep object), passing 'True' as first argument, but it doesn't work in my project : the printer dialogBox does not appear ...

    To have more information on the printOut method, you can go to PrintOut

    Hope it will help you ...
    Good luck

    Nathy1210

  4. #4
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188

    Re: How can I view and take printout of crystal report?

    For VB.NET 2005
    VB Code:
    1. Dim application As New CRAXDDRT.Application
    2. Dim report As New CRAXDDRT.Report
    3.  
    4. report = application.OpenReport("reports/projects.rpt", 1)
    5. report.RecordSelectionFormula = "({command.idjobs})= " & myvariable
    6. report.ExportOptions.FormatType = CRExportFormatType.crEFTPortableDocFormat
    7. report.ExportOptions.DestinationType = CRExportDestinationType.crEDTApplication
    8. report.ExportOptions.ApplicationFileName = "reports/pdf/projects.pdf"

    I send all my reports to PDF. It is usually a smaller file and allows the file to be read by virtually anybody.

  5. #5
    Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    34

    Re: How can I view and take printout of crystal report?

    Hi Nathi ,

    I tried your codes with form1 and form2 but i am getting error "User defined type not defined" i have set crystal report control and crysyal report viewer control in my components and in reference crystal report viewer control and crystal report 8.5 library.

    I have VB6 and access database and CR 8.5

  6. #6
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188

    Re: How can I view and take printout of crystal report?

    Which lines cause the error? This will help us figure out your issue better.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: How can I view and take printout of crystal report?

    Quote Originally Posted by craigreilly
    Which lines cause the error? This will help us figure out your issue better.
    Hi, I am also getting the same error. Please find attched the jpg file.
    Using Crystal Reports XI, MS Access database
    Crystal AcitveX Report Viewer Library 11.0



    Regards,

    Seema_S
    Attached Images Attached Images  

  8. #8
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188

    Re: How can I view and take printout of crystal report?

    Sorry - I am getting the same error in VB6/CR10. I will do some additional research and see why. I am sure it has to do with the References and Components.

    I am sure v11 'seema' will be similar.

  9. #9
    Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    34

    Re: How can I view and take printout of crystal report?

    I Got the solution to it. Just add reference to crystal reports 8.5 Active X Desiner Run Time Library. If you are using CR XI add accordingly.

  10. #10
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188

    Re: How can I view and take printout of crystal report?

    So here was my final VB6 code with Crystal 10 - export to PDF.
    My only refernce was 'Crystal Reports Active X Designer Runtime Library 10'
    I did not use any components since I went directly to PDF.
    There are about 10 or so different export option types. Play with the * line to see them... XML, Excel, CSV, Word, HTML

    VB Code:
    1. Dim Application1 As New CRAXDRT.Application
    2. Dim Report As New CRAXDRT.Report
    3.  
    4. Set Report = Application1.OpenReport("c:\projects.rpt")
    5. Report.ExportOptions.FormatType = CRExportFormatType.crEFTPortableDocFormat '*
    6. Report.ExportOptions.DestinationType = CRExportDestinationType.crEDTApplication
    7. Report.ExportOptions.ApplicationFileName = "c:\projects.pdf"
    8. Report.Export (False)
    9. Set Report = Nothing
    10. Set Application1 = Nothing

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: How can I view and take printout of crystal report?

    Quote Originally Posted by craigreilly
    So here was my final VB6 code with Crystal 10 - export to PDF.
    Yes, it is working fine. Do you have any sample example/code to get prints of Datagrid/ListViews?

    Seema_S

  12. #12
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188

    Re: How can I view and take printout of crystal report?

    I would normally just use the Crystal Reports to get a printout of the datagrid/listview...
    I know it can be done on listview. try searching around the forums or post a new question.

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