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
Printable View
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?Quote:
Originally Posted by seema_s
Regards.
Seema_s
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:
Private Sub Command2_Click() Dim CrAppl As New CRAXDRT.Application Dim CrRep As New CRAXDRT.Report Set CrRep = CrAppl.OpenReport("C:\...\XXX.rpt") With CrRep 'Selection .RecordSelectionFormula = "{table.field} = 'value'" 'Parameters .ParameterFields.Item(1).AddCurrentValue "Title" .ParameterFields.Item(2).AddCurrentValue "NoDate" 'Order (on the field 'fieldname' from the 1st table on the report Call .RecordSortFields.Add(.Database.Tables(1).Fields.GetItemByName("fieldname"), crAscendingOrder) End With 'To view with the viewer Screen.MousePointer = vbHourglass Form2.CRViewer1.ReportSource = CrRep Form2.CRViewer1.ViewReport DoEvents Screen.MousePointer = vbDefault Form2.Show 'To Print without viewing the report Form2.CRViewer1.ViewReport DoEvents Screen.MousePointer = vbDefault Form2.CRViewer1.PrintReport 'Full screen Form2.Top = 0 Form2.Left = 0 Form2.Width = Screen.Width Form2.Height = Screen.Height - 400 Form2.CRViewer1.Top = 0 Form2.CRViewer1.Left = 0 Form2.CRViewer1.Width = Form2.Width Form2.CRViewer1.Height = Form2.Height 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
For VB.NET 2005
VB Code:
Dim application As New CRAXDDRT.Application Dim report As New CRAXDDRT.Report report = application.OpenReport("reports/projects.rpt", 1) report.RecordSelectionFormula = "({command.idjobs})= " & myvariable report.ExportOptions.FormatType = CRExportFormatType.crEFTPortableDocFormat report.ExportOptions.DestinationType = CRExportDestinationType.crEDTApplication 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.
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
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.Quote:
Originally Posted by craigreilly
Using Crystal Reports XI, MS Access database
Crystal AcitveX Report Viewer Library 11.0
Regards,
Seema_S
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.
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.
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:
Dim Application1 As New CRAXDRT.Application Dim Report As New CRAXDRT.Report Set Report = Application1.OpenReport("c:\projects.rpt") Report.ExportOptions.FormatType = CRExportFormatType.crEFTPortableDocFormat '* Report.ExportOptions.DestinationType = CRExportDestinationType.crEDTApplication Report.ExportOptions.ApplicationFileName = "c:\projects.pdf" Report.Export (False) Set Report = Nothing Set Application1 = Nothing
Yes, it is working fine. Do you have any sample example/code to get prints of Datagrid/ListViews?Quote:
Originally Posted by craigreilly
Seema_S
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.