Solved

Automate Generate Crystal Report

Posted on 2002-04-08
9
439 Views
Last Modified: 2012-06-27
Hi,

Does anyone know how to automate to generate the crystal report with data and then save it to crystal report format or html format or excel format or text format?

I knows that crystal report able to export the crystal report to other supported format by click on the button when viewing the report.

My question is, is there a way not to allow user click on those button? Meams, automatic generate the report?

Urgent matter need your expertise and ideas and solutions!

Thanks.

0
Comment
Question by:ht055
  • 5
  • 4
9 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 6928605
If you are refering to the export icn on the CR viewer, you can make it visible or invisible from VB.

If you are using the ActiveX control you use the following

  CR_Report.WindowShowExportBtn = False

To automatically generate a file you can do something like this

Public Sub print_File_from_View(txt_Report_File_Name As String, _
                            txt_Rec_Select_Formula As String, _
                            txt_Disk_File_Name As String)

    cr_Rpt.ReportFileName = txt_Report_File_Name
    cr_Rpt.ReplaceSelectionFormula txt_Rec_Select_Formula
    cr_Rpt.Destination = crptToFile
    cr_Rpt.PrintFileType = crptWinWord
    cr_Rpt.PrintFileName = txt_Disk_File_Name
    cr_Rpt.ProgressDialog = False
    cr_Rpt.PrintReport
   
    cr_Rpt.Reset
       
End Sub


PrintFileType can have many different values depending on what convertors you have loaded. (Excel, text, CSV, etc)

good luck
mlmcc
0
 

Author Comment

by:ht055
ID: 6930894
Hi mlmcc,

thank you very much for you reply as i was waited for a day!!!!

Based on your solution, my have question for your clarification.

1. Is the user need to click on the export icon in CR viewer? I don't want user to click on any icon to export the file. Which means end of the month, the system auto generate the report without user involved.

2. You public function does the automation generation of report?

Thanks.

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6932919
Yes it will automatically generate the file.  In fact we generate the file and then e-mail to the customer.

mlmcc
0
 

Author Comment

by:ht055
ID: 6933077
ic...so you had done the automate the report generation project. That good!

Appreciate if you could show me an working example code (full) to automate the report generation.

The mark definetely is for you!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 100

Expert Comment

by:mlmcc
ID: 6935766
Basically what I gave you is a full example.  There are a couple of declarations and then the components you must add.  I'll try to find it tonight otherwise I'll add it at work tomorrow.

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6935791
Here is an example from Crystal.  You may find it useful.  I'll still provide what i have.

http://support.crystaldecisions.com/communityCS/FilesAndUpdates/aspxmps85.exe.asp

mlmcc
0
 

Author Comment

by:ht055
ID: 6936037
hi mlmcc.

Thank you very much.

You can send to ht055@hotmail.com

Thanks again!
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 100 total points
ID: 6937054
Unfortunately my application is much to large to send and is very database specific (MS SQL) but here is a documented excerpt from the code with the required references.  This will create the report in a file ready to be opened by the application  It ispossible to have the application started from VB after the report is complete and open the file.


Add the following component to the project
PROJECT --> COMPONENTS
Crystal Report Control

Add the following references to the project
PROJECT --> REFERENCES
Crystal Reports 8 ActiveX Designer Design Time Library
Crystal Reports 8 ActiveX Designer Run Time Library
Crystal Reports 8 Standard Wizard Library


On the MDI form or a form used to print the report add the following

DECLARATIONS section

‘  Create a Crystl Report object  - uses the ActiveX control

Dim WithEvents cr_Generic_Report As CrystalReport


Behind the Button or in a procedure add the following code to print to the file


‘  Set the report to produce.  Must unclude the full path, filename and extension

    cr_Generic_Report.ReportFileName = “c:\Database\Reports\My_Report.rpt”

‘  Allows changing the WHERE clause of the query

    cr_Generic_Report.ReplaceSelectionFormula “{view_rpt_My_Report.id} = 5”

‘  Where do you want the report to go
‘     File               crptToFile
‘     Preview          crptToWindow
‘     Printer               crptToPrinter
‘     Mail               crptMapi
‘     MS Exchange          crptExchange

    cr_Generic_Report.Destination = crptToFile

‘  If you are going to a file what type and the file name
‘     MS Word     crptWinWord
‘     MS Excel     crptExcel50
‘     Text File     crptText
‘     RTF File     crptRTF

    cr_Generic_Report.PrintFileType = crptWinWord
    cr_Generic_Report.PrintFileName = “c:\my_documents\my_report04022002.doc”

‘  Display the progress dialog box

    cr_Generic_Report.ProgressDialog = False

‘  Execute the report


    cr_Generic_Report.PrintReport

‘  Reset the Crystal Object – allows printing multiple reports
‘    
    cr_Generic_Report.Reset


good luck
mlmcc
0
 

Author Comment

by:ht055
ID: 6941572
hi mlmcc,

would test out the your code.

thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now