VB6 and CR 8.5 integration 
Author Message
 VB6 and CR 8.5 integration

Hello,
    Can someone point me in the direction where I could find a decent book
about integrating Crystal Reports and VB? I have already created all the
reports I plan to use in my application, however, I can't seem to figure out
how to use the Crystal reports viewer that was Seagate provided when I
installed CR (8.5).
    Alternatively, could someone help me out with the "Server has not yet
been opened." error? I tried to use Application.LogonServer, but it wants a
dll as the first parameter? What dll is it looking for?

Thanks a lot

Jason



Sat, 20 Nov 2004 20:24:41 GMT  
 VB6 and CR 8.5 integration
Once u a using the viewer, there are different ways to call the report. This
is the way I did:
1.Create a form with the crviewer control
2. create some global variables or call the form with parameters of which
report to print
here is some a sample of the code the the report.frm file

Private Sub Form_Activate()
'     On Error GoTo ReportError
    On Error Resume Next
    Set lRdApp = CreateObject("CrystalRuntime.Application")
    Set Report = lRdApp.OpenReport(gReportTemplate)
    For i = 1 To Report.Database.Tables.Count
        Set crpTable = Report.Database.Tables.Item(i)
        crpTable.SetLogOnInfo gServerName, gDatabaseName, "sa", ""
    Next i
    Set crpParamDefs = Report.ParameterFields
    Screen.MousePointer = vbHourglass

    If gstrSQL <> "" Then
        Report.SQLQueryString = gstrSQL
    ElseIf gSelectionFormula <> "" Then
        Report.RecordSelectionFormula = gSelectionFormula
    End If
    If gParameters <> "" Then
        For Each crpParamDef In crpParamDefs
            With crpParamDef
                Select Case .ParameterFieldName
                    Case "TotalMonths"
                        .SetCurrentValue (gParameters)
                    Case "StatementDate"
                        .SetCurrentValue (CDate(gParameters))
                    Case "datesent"
                        .SetCurrentValue (CDate(gParameters))
                    Case "Custnum"
                        .SetCurrentValue (gClientCode)
                    Case "DateSelect"
                        .SetCurrentValue (CDate(gParameters))
                    Case "AddPrem"
                        .SetCurrentValue CDbl(gParameters)
                End Select
            End With
        Next
    End If
    CRViewer1.ReportSource = Report
    'Suppress detail line
    Report.Sections("D").Suppress = gSuppressD

    Report.ReportTitle = gReportTitle
    Report.UseIndexForSpeed = True
    Report.VerifyOnEveryPrint = True
    'Report.PaperSource = crPRBinEnvelope
    Screen.MousePointer = vbDefault
    If gReportPrintNow = False Then
        Me.Caption = gReportTemplate
        CRViewer1.ViewReport
    Else
        Report.PrintOut False, 1, False, 1
        Unload Me
    End If
    gSelectionFormula = ""
    gReportTemplate = ""
    gReportTitle = ""
    gParameters = ""
    gSearchTitle = ""
    gReportPrintNow = False
    '//*** ERROR-STUB ADDED BY ADD-IN
    Exit Sub

ReportError:
    MsgBox "[" & Err.Number & "] " & Err.Description, vbInformation,
"Form_Load - Error"
    Resume Next
End Sub

'//***
************************************************************************
Private Sub Form_Load()

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    gReportTemplate = ""
    Set crpTables = Nothing
    Set crpTable = Nothing
    Set crpParamDefs = Nothing
    Set crpParamDef = Nothing
    Set lSections = Nothing
    Set Report = Nothing
    gSuppressD = False
    Set lRdApp = Nothing
    '     lRdApp.LogOffServer "p2ssql.dll", "SERVERNAME", "Databasename",
"sa", ""
    Set frmReport = Nothing
End Sub

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

End Sub

hopefully this helps
Vincent



Sat, 20 Nov 2004 21:55:54 GMT  
 VB6 and CR 8.5 integration
Hello Vincent,

For the moment, I use the Crystal ocx-control in my VB applications.

Can you tell me the difference between using this ocx-control and using de
crviewer-control?

Many thanks and greetings from Brugge (Bruges - Belgium),

Michel



Quote:
> Once u a using the viewer, there are different ways to call the report.
This
> is the way I did:
> 1.Create a form with the crviewer control
> 2. create some global variables or call the form with parameters of which
> report to print
> here is some a sample of the code the the report.frm file



Sat, 20 Nov 2004 22:08:09 GMT  
 VB6 and CR 8.5 integration
The OCX control, though it is good, it really is there for backward
compatibility (remember the version 4.0 days) and crystal is mum about
support for it. The crviewer gives you more flexibility and unlike the ocx
control, has many more runtime enhancements and tweakings than its ocx
sibling.
Once I changed from the ocx to the viewer I noticed a speed increase right
away.
The biggest problem with the viewer is that even though its in its 8.5
version, crystal still can't get the runtime requirement files right
(especially when you deal with SQL server)

Vincent


Quote:
> Hello Vincent,

> For the moment, I use the Crystal ocx-control in my VB applications.

> Can you tell me the difference between using this ocx-control and using de
> crviewer-control?

> Many thanks and greetings from Brugge (Bruges - Belgium),

> Michel



> > Once u a using the viewer, there are different ways to call the report.
> This
> > is the way I did:
> > 1.Create a form with the crviewer control
> > 2. create some global variables or call the form with parameters of
which
> > report to print
> > here is some a sample of the code the the report.frm file



Sun, 21 Nov 2004 23:10:41 GMT  
 VB6 and CR 8.5 integration
Hello Vincent,

Thank you for your answer.
I am working with an Access database.  Can you tell me if those problems
with the runtime rewuirement files are there also with an Access database.
What are the consesquences of those problems with the runtime requirement
files?

Many thanks and greetings from Brugge (Bruges - Belgium),

Michel



Quote:
>> The biggest problem with the viewer is that even though its in its 8.5
> version, crystal still can't get the runtime requirement files right
> (especially when you deal with SQL server)



Mon, 22 Nov 2004 15:52:34 GMT  
 VB6 and CR 8.5 integration
No with access we have not encountered this problem. However, you need the
latest mdac_typ.exe file preferable version 2.6 or later. We noticed that
once you have office XP installed on the machine, the error does not show up

Quote:
> Hello Vincent,

> Thank you for your answer.
> I am working with an Access database.  Can you tell me if those problems
> with the runtime rewuirement files are there also with an Access database.
> What are the consesquences of those problems with the runtime requirement
> files?

> Many thanks and greetings from Brugge (Bruges - Belgium),

> Michel



> >> The biggest problem with the viewer is that even though its in its 8.5
> > version, crystal still can't get the runtime requirement files right
> > (especially when you deal with SQL server)



Mon, 22 Nov 2004 23:04:57 GMT  
 VB6 and CR 8.5 integration
Jason,

LogOnServer is the way to go.  First, flush your data, though.  I think not
discarding the data stored with the report is how I used to get the Server
Not Open error -- which is just a misleading error message, as far as I can
tell.  To get the dll name, you can just use the dll name that is stored
with the report:   CrxRpt.Database.Tables(1).DllName.

Here's the code that works for me in VB:
With CrxRpt.Database
            .DiscardSavedData
            .LogOnServer CrxRpt.Database.Tables(1).DllName, _
            ParseToken(sConnection, "Data Source"), _
            ParseToken(sConnection, "Initial Catalog"), _
            ParseToken(sConnection, "USER ID"), _
            ParseToken(sConnection, "Password")
        End With

James Ashley


Quote:
> Hello,
>     Can someone point me in the direction where I could find a decent book
> about integrating Crystal reports and VB? I have already created all the
> reports I plan to use in my application, however, I can't seem to figure
out
> how to use the Crystal reports viewer that was Seagate provided when I
> installed CR (8.5).
>     Alternatively, could someone help me out with the "Server has not yet
> been opened." error? I tried to use Application.LogonServer, but it wants
a
> dll as the first parameter? What dll is it looking for?

> Thanks a lot

> Jason



Mon, 06 Dec 2004 01:27:32 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Need Help CR 8.5 + VB6

2. VB6 (SP5) and CR 8.5 Dev Problems...

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

4. CR 8.5 Crashes in VB6 (ole32.dll)

5. CR 8.5 developer crashes machine in VB6

6. CR 8.5 and CR from VS.Net package

7. Decimal Place problem after Upgrading from CR 6 to CR 8.5

8. CR 8 and CR 8.5

9. Using a dll that referenced CR 8.5 files on a machine that has CR 8.0

10. Crystal 8.5 Professional and integration in VB-Projects

11. Lost VB IDE Help integration with 8.5

12. Parameter to Stored Procedure CR 8.5 VB.Net Specified Cast Not Valid

 

 
Powered by phpBB® Forum Software