Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
| Search | Today's Posts | Mark Forums Read
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 7th, 2008, 09:46 AM
Registered User
Join Date: Feb 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default CRD vba code no longer works

I use the crystal report designer i to export a crystal report as a tab separated text from Microsoft Access. The report was originally written in Crystal 8.5 and connected to the Oracle back end database via ODBC.

This code worked:

Public Function ExportCrystalReport(strReportLocation As String, _
                                    strReportFileName As String, _
                                    strExportLocation As String, _
                                    strExportFileName As String, _
                                    Optional intParameterValue As Integer = 0) As Boolean

Dim crxApp As New CRAXDRT.Application
Dim crxReport As CRAXDRT.Report
Dim crxParameter As CRAXDRT.ParameterFieldDefinition

On Error GoTo ErrHandler

    Set crxReport = crxApp.OpenReport(strReportLocation & strReportFileName)

    crxApp.LogOnServer "pdsora7.dll", "EMS", , "XXXX", "xxxx"

    With crxReport
        With .ExportOptions
            .DiskFileName = strExportLocation & strExportFileName
            .DestinationType = crEDTDiskFile
            .FormatType = crEFTTabSeparatedText
        End With

        If intParameterValue = 0 Then
            Debug.Print .ParameterFields.Count
            Debug.Print .ParameterFields.Item(1).Name
            .ParameterFields.Item(1).AddCurrentValue intParameterValue
        End If

        'Don't prompt for export options
        .Export False
    End With

    Set crxReport = Nothing

    crxApp.LogOffServer "pdsora7.dll", "EMS", , "XXXX", "xxx"

    Set crxApp = Nothing
    ExportCrystalReport = True

    Exit Function

    ExportCrystalReport = False
    MsgBox "Error whilst exporting the report " & strReportFileName, vbCritical

End Function

However, we have since upgraded to crystal 10 standard edition so the ODBC link is no longer available. The report now connects using the Microsoft OLEDB provider for Oracle. I've changed the references in Access so that the "Crystal reports ActiveX Designer Run time Library 10.0" is referenced rather than the 8.5 version. I've also changed the log on server command so that it uses the P2Soledb.dll to connect to the database. This appears to be ok as I can view details about the report (eg crxreport.ReportAuthor) but I now get an error at the ".Export false" line.

Anyone got any ideas? Am I using the correct logonserver line?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Code that works !! for chapter 3 dawsonje44 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 March 2nd, 2007 04:33 PM
Wrox Press C++ Tutorial no longer works bruce_x15 Visual C++ 3 June 19th, 2006 03:37 PM
PHP code - works in Firefox, fails in IE gingerbraid Beginning PHP 13 October 6th, 2005 06:33 PM
code works in IE but not netscape Toka1 Javascript How-To 2 November 27th, 2003 05:35 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.