Run Crystal Report VB 6.0

BJ JMU
12-22-2003, 08:44 AM
I have been searching and trying many different things to run a crystal report from vb6.0. here is my code as of now:

-----------------------------------------------------------------

Dim crxApp As CRAXDRT.Application
Dim crxReport As CRAXDRT.Report
Dim CRViewer As CRViewer9

Set crxApp = CreateObject("crystalruntime.application")
Set crxReport = crxApp.OpenReport("\\Report Path\ReportName.RPT")


crxReport.Database.Tables(1).SetLogOnInfo "ServerName", "DatabaseName", "UserName", "Password"


Screen.MousePointer = vbHourglass
***CRViewer.ReportSource = crxReport
CRViewer.ViewReport
Screen.MousePointer = vbDefault

----------------------------------------------------------------

I am getting a run-time error '91'
object variable or with block variable not set

and that points me to the line with the ***'s

can anyone see what i'm doing wrong?

jezzerdilla
12-22-2003, 08:51 AM
Right then...

The Crviewer is a control and should be drawn on the form, then referenced. You then will be able to set it's properties. You can not instanciate a crviewer control at runtime.

BJ JMU
12-22-2003, 09:01 AM
Right then...

The Crviewer is a control and should be drawn on the form, then referenced. You then will be able to set it's properties. You can not instanciate a crviewer control at runtime.

I should have figured that one out...What I am trying to do is just call a report so that crystal reports opens and runs the report. I think I am going about this in the wrong way...

BJ JMU
12-22-2003, 09:06 AM
I added the viewer on the form and got rid of the declaration of the view I had before (Dim CRViewer as....)

So now it seems to work fine but gives me a "logon failed" error. Is there something wrong with my logon?

Also I would prefer to not use the viewer, unless it is easier to handle that way. Eventually what i want to do is save the report in different styles i.e. as a pdf file, as a crytal report, e-mailed etc. but as of right now i'm just trying to get the report to run :)

thanks

jezzerdilla
12-22-2003, 09:22 AM
I added the viewer on the form and got rid of the declaration of the view I had before (Dim CRViewer as....)

So now it seems to work fine but gives me a "logon failed" error. Is there something wrong with my logon?

Also I would prefer to not use the viewer, unless it is easier to handle that way. Eventually what i want to do is save the report in different styles i.e. as a pdf file, as a crytal report, e-mailed etc. but as of right now i'm just trying to get the report to run :)

thanks


I had alsorts of fun with the crstal reports, I'll include a small dll project you can look at and nick some code... These reports were created using the a file definition file (ttx). I used this method as it meant that no Oracle/Database reference was being held in the report.


Ive cut a looad of the crap out of the project so you'll need to work on it a bit

Enjoy

BJ JMU
12-22-2003, 01:35 PM
i figured out that all the code was correct but i had not installed the odbc drive for the particular database i was trying to access. stupid me. thanks for you help though :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum