2 Replies - 75 Views - Last Post: 08 February 2020 - 01:43 AM Rate Topic: -----

#1 clynnekent   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-February 20

ERROR MISSING FORMULA IN CRYSTAL REPORT

Posted 07 February 2020 - 06:52 AM

Good day everyone. I'm started to learning Crystal Report Anyone can help me about this error is there any missing of my code? I'm using VB 2010 and MS Access 2007 and Crystal Report 2013.

Here is my code:
Imports CrystalDecisions.CrystalReports.Engine

    
Public Class Form2



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        CrystalReportViewer1.ReportSource = Application.StartupPath + "\CrystalReport1.rpt"
        CrystalReportViewer1.SelectionFormula = "{Product.Product_name}= '" & TextBox1.Text.ToString() & "''"
        CrystalReportViewer1.Refresh()
        CrystalReportViewer1.RefreshReport()

    End Sub
End Class


Thanks in advance

clynnekent

This post has been edited by xclite: 07 February 2020 - 06:56 AM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: ERROR MISSING FORMULA IN CRYSTAL REPORT

#2 xclite   User is offline

  • I wrote you an code
  • member icon


Reputation: 1430
  • View blog
  • Posts: 4,282
  • Joined: 12-May 09

Re: ERROR MISSING FORMULA IN CRYSTAL REPORT

Posted 07 February 2020 - 06:55 AM

Please use code tags, please say what the full error actually is, please don't yell at us.
Was This Post Helpful? 0
  • +
  • -

#3 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 394
  • View blog
  • Posts: 1,648
  • Joined: 07-September 13

Re: ERROR MISSING FORMULA IN CRYSTAL REPORT

Posted 08 February 2020 - 01:43 AM

This is going completely from memory, so some of this may be wrong.

Personally I think you need to go back right to the beginning and set up your environment, you currently have option strict off, you want to turn that on, this can be done in the projects properties, under Compile.

You can also set it so it will automatically be set to on, through Tool --> Options

Now depending on how long you have been doing this application, that may highlight a lot of issues where potential casts are not being done, if that's the case you "can" turn it back off (so you don't have to fix the issues immediately) and add the following code right at the top of this class, above the using statements. However, you should go back and fix the other locations.

Option Strict On


Now that should highlight this line as a invalid cast:

CrystalReportViewer1.ReportSource = Application.StartupPath + "\CrystalReport1.rpt"


So if I am right, this actually has nothing to do with your formula but your report source. the property ReportSource on CrystalReportViewer is expecting a object of type ReportDocument, whereby you have given it a string.

  
  Dim crystalReport = new ReportDocument()
  crystalReport.Load(Application.StartupPath + "\CrystalReport1.rpt") ' <-- there is some overloads here but I can't remember what they are.
  CrystalReportViewer1.ReportSource = crystalReport 



As stated this is completely from memory and I have legit just typed that code on this website, so the chances of issues are there, for example I know the object is called ReportDocument but I don't know what namespace that is under, it could be under the 'CrystalDecisions.CrystalReports.Engine' namespace which you already have imported, but it might not be.

I don't have crystal installed on my home computer to check.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1