Friday, March 9, 2012

How to Add Crystal Reports 9 into VB 6 Project

Hi! All!

I can't add Crystal Report 9 into VB 6 Project.

I already Create Crystal Report 9 and I try to add Crystal Reports controls into VB 6 application Project -- > components & reference also.

What are all the controls(dll or ocx) to be added in VB application components & reference for import Crystal Reports 9 into VB 6 Application.

Can any one tell me how to add Crystal Reports 9 into VB 6.

Thanks

- RajaExtracted from --> http://www.mahipalreddy.com/cr/crcodes1.htm
'Code by Mahipal Padigela
'Add a Command button to your Form(Form1)
'Add a Form(Form2) to the project and add a 'Crystal Report Viewer Control 9' from Project-->Components to it.
'Reference 'Crystal Reports 9 ActiveX Designer Run Time Library' from Project-->References
'Replace "C:\myCRReport.rpt" with your CR Report file path
'Replace the value of strSelectionfrm variable with your selection formula
'Paste the following in to the code window of your form

Private Sub Command1_Click()
Dim crApp As CRAXDRT.Application
Dim Report As CRAXDRT.Report
Dim strSelectionfrm As String
Set crApp = New CRAXDRT.Application
Set Report = crApp.OpenReport("C:\myCRReport.rpt")

'You don't need the next line of code if you are using a MS Access databse, but if you are using
'any other databse then Crystal reports expects you to pass Logon credentials before opening the report. So replace the
'DSN name, Databse name, user name, password with yours. Though the next line of code is passing Logon info to
'only the first table in the Tables array of the report, in theory, it should work fine as crystal passes the same info to any other
'tables in the report.For more info on passing Logon credentials to each and every table in the main report as well as all subreports,
'please refer to my article programmatically exporting Crystal Reports to PDF and other formats

Report.Database.Tables(1).SetLogOnInfo "DSN name", "Databse name", "user name", "password"

'Replace the value of strSelectionfrm variable with your selection formula
strSelectionfrm = "{Expected_Sales.Dept}='Analyst Group' and {Expected_Sales.Qtr}='Qtr1'"
Report.RecordSelectionFormula = strSelectionfrm
Report.DiscardSavedData
Form2.CRViewer91.ReportSource = Report
Form2.CRViewer91.ViewReport
Form2.Show
End Sub|||Tq for reply.

I already add Crystal Reports controls in Project components & also Reference.

But still I can't add Crystal Report into my VB 6 Project.

I attach with screen shots for adding components & references for Crystal Reports 9 controls.

http://www.dev-archive.com/forum/attachment.php?attachmentid=&stc=1

After add these controls we can directly add crystal report from Project Menu (like Add Crystal Report).

Is it true or not?

If it is true there is no more option to add Crystal Report in Project Menu.

I can't use Crystal Reports coding like

Dim crApp As CRAXDRT.Application
Dim Report As CRAXDRT.Report
Dim strSelectionfrm As String
Set crApp = New CRAXDRT.Application
Set Report = crApp.OpenReport("C:\myCRReport.rpt")

in my Project.

Can you please tell me what's wrong in my project.

Is Crystal Reports 9 Problems or VB 6 Problems?

Thanks.

- Raja|||either you i havent understood exactly what you are trying to ask,
but if no,
then you can just add .rpt file of the Crystal Reports,like this..
right click Project in solution Explorer, Add->File-> and just choose your .rpt file. VB6 will attatch the .rpt file as .dsr file.and you can directly use its relative path,by creating instance of that .dsr file.thats it.|||Tq for reply.

I already add .rpt file into my VB project. But it is saved as in module(Not in .dsr file).

Is any other crystal controls needed to add in VB Project?

I can try to Reinstall Crystl Reports 9 & add controls into VB Project again.

Still I can't find out any other controls related to Crystal Report Designer or Viewer in my VB tool box controls.

What I need to change for add Crystal Reports 9 into my VB project?

Can anyone send more details about these problem.

Thanks.

- Raja

No comments:

Post a Comment