Crystal Reports 8.5/VBA "Server has not yet been opened" error. 
Author Message
 Crystal Reports 8.5/VBA "Server has not yet been opened" error.

I am using:
Windows 2000 Professional
Valid MS SQL 8.00.194 server
Valid ODBC Datasource with SQL Server authentication
Crystal Reports Developer 8.5.0.217
VBA 6

When trying to preview a report using the Crystal Reports Viewer
component in VBA, it works fine when I am either connecting to the
database, or using parameters. When using both, I get the "Server has
not yet been opened" error.

The code:

'-------------------------------------------------

Option Explicit

Dim crApplication As New CRAXDRT.Application
Dim crReport As CRAXDRT.Report

Public Sub doPrint(reportName As String, serverName As String, dbName
As_
String, dbUser As String, dbPassword As String)

Dim CRXParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim CRXParamDef As CRAXDRT.ParameterFieldDefinition

Set crReport = crApplication.OpenReport("c:\reportName.rpt")

crReport.Database.Tables(1).SetLogOnInfo serverName, dbName, dbUser,
dbPassword

Set CRXParamDefs = crReport.ParameterFields
For Each CRXParamDef In CRXParamDefs
    With CRXParamDef
        Select Case .ParameterFieldName
            Case "invoice_num"
            .SetCurrentValue 111, crNumberField
        End Select
    End With
Next

crReport.EnableParameterPrompting = False
form1.CRViewer2.ReportSource = crReport
form1.CRViewer2.ViewReport

End Sub

'---------------------------------------------------

The culprit line seems to be ".SetCurrentValue 111, crNumberField".
Removing it removes the error and the report seems to load fine. When
the line is present, the CRViewer object stays blank and the error
pops up. The line "form1.CRViewer2.ViewReport" seems to be raising the
error.

The code seems to be working under 2 conditions:
1. I do not have the SetLogonInfo statement and use a static report
(no data from database).
2. I remove the parameter parts (more specifically, the line
'.SetCurrentValue 111, crNumberField'.

I have a single parameter in my report named "invoice_num" which is of
type "number".

In Crystal Reports, the report seems to access the database correctly
as it displays information from the DB in the preview tab.

There does not seem to be a similar error condition on the Crystal
Decisions website knowledge base.

Any help/suggestions/patch suggestions will be greatly appreciated!

thanks in advance
Neil



Fri, 13 Aug 2004 22:18:04 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Error: "Server not yet opened"

2. "server not yet opened" error

3. "server not yet opened" error

4. Crystal 8.5 "Server not yet opened" error

5. "the server is not yet opened"

6. "Server not yet opened"

7. Server Has not yet been opened Error with Crystal Reports 7

8. VB6 and CR 8.5 Server has not yet been opened

9. 8.5 / ASP / Server has not yet been opened

10. Connection not Open + Server has not yet been opened error messages

11. Crystal 8, VB Script Server has not yet been opened Error

12. "Server not yet opened" Error when opening report form

 

 
Powered by phpBB® Forum Software