Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Crystal Reports from Visual Basic

Status
Not open for further replies.

amutinu

Programmer
Oct 19, 2001
50
US
Hello All,
I am new to crystal reports and am trying to run a report from visual basic 6.0 I have crystal reports 8.5 professional version. I have already created a sample report which runs fine in crystal report application. Now i am trying to run it from visual basic, can someone please tell me how to do this? Any sample code or suggestions would be greatly appreciated.

Thanks,
 
put these in the module

Public CRapp As CRAXDRT.Application
Public CRrpt As CRAXDRT.Report

create 2 forms

make a cmd button and put this inside

Private Sub cmdButton()
Set CRapp = CreateObject("crystalruntime.application")
Set CRrpt = CRapp.OpenReport("report_name.rpt")
form2.Show
End Sub

Make form 2 and add a CRViewer control to it which you add in References

then add this to the code

Private Sub Form_Load()
CRViewer1.ReportSource = CRrpt
CRViewer1.EnableAnimationCtrl = False
CRViewer1.EnableRefreshButton = True
CRViewer1.EnableGroupTree = False
CRViewer1.EnableNavigationControls = True
CRViewer1.ViewReport
End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub


that should work i think
 
Thanks for your feedback but when i put the code in a project and try to run it, it doesn't recognize the following code:

Public CRapp As CRAXDRT.Application
Public CRrpt As CRAXDRT.Report

It gives me an error:
"User defined-types not found"

I am not sure what this means. Can you please let me know. Again I have crystal reports 8.5 professional version. Do i need to download a seperate dll. I even checked the winnt\system32 and i do not have "craxdrt" dll.

Your help is greatly appreciated
 
I actually found the craxdrt dll. It was not registered in system32 but was stored in "seagate software\Report Designer Component." So once i registered the dll, i was able to execute the code and it runs fine.

Although i would i change the code so that i can supply in the sort criteria?

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top