Crystal report

Posted on 2011-05-12
Last Modified: 2012-05-11
Hi when i call the report it appears blank and a error window with no msg in it and second error window with sql server error. My crystal report is connected to a STORED PROC. The report independently runs

Private Sub Form_Load()

Dim CrApp As CRAXDRT.Application
Dim CrRep As CRAXDRT.Report
Dim oCrystalParameters As CRAXDRT.ParameterFieldDefinitions
Dim CrtParameters As CRAXDRT.ParameterFieldDefinitions
Dim CrtParameter As CRAXDRT.ParameterFieldDefinition

Dim dd As String
dd = "YIOP2795776"

Set CrApp = New CRAXDRT.Application
Set CrRep = CrApp.OpenReport("C:\J.rpt")
 CrRep.Database.Tables.Item(1).SetLogOnInfo "server", "db", "uname", "pwd"
 CrRep.EnableParameterPrompting = False


Set CrtParameters = CrRep.ParameterFields
For Each CrtParameter In CrtParameters
  If CrtParameter.Name = "{?@strOrderNo}" Then
       CrtParameter.AddCurrentValue dd
  End If
Next CrtParameter

CRViewer1.ReportSource = CrRep
Set CrRep = Nothing
Set CrApp = Nothing
End Sub
Question by:AnnaJames77
    LVL 69

    Assisted Solution

    by:Éric Moreau
    instead of having CR feeding itself from the SP, load a dataset and push it to your report:
    LVL 21

    Expert Comment

    Don't you need error handling, and what is the sql error message?
    LVL 100

    Assisted Solution

    Try putting the DiscardSavedData line right after the OpenReport

    LVL 100

    Accepted Solution

    Another thing to try

    Comment this line out
    CrRep.EnableParameterPrompting = False

    Does the report prompt for a value and then run correctly?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now