Skip to Content
avatar image
Former Member

Error in formula <Record_Selection> This field name is not known.

I'm have a very frustrating time getting this report to work.

Version CR: 11.5 R2A SP6 (11.5.3700)

I am adding a new report to a well established application developed in VB 2005.

The application is using the CR SDK to accomplish most things.

My form (crptInsulationReportSummary) is connected to a SQL Server 2008 data source.

While in development mode I can select the "Main Report Preview" tab and see that the report is connected properly and that data shows up in the report.

When the application is run the following occurs in the order presented:

clsInsulationReportSummary.InitializeDataSet()

call PrintInsulationReportSummary()

     CrystalReportsHelper.DatabaseIntializationLion

     InsulationSummaryReport.RecordSelectionFormula = ...

     InsulationSummaryReport.SetDataSource( ...

The code for the above routines is pasted below.

It seems very simple and straightforward, however no matter what I try (I've even deleted the report and started from scratch) I keep getting the following error depicted in the image below.

I'm not getting an error, per se, just a blank report, but when I dig through the object this is what I find.

Let me know if you need any more information.

Thank you.

Tim Caldwell



(contents for above calls)

Public Class clsInsulationReportSummary

    Public Shared dsInsulationReportSummary As DataSet

    Public Shared Sub InitializeDataSet()

        dsInsulationReportSummary = New DataSet

        dsInsulationReportSummary.Tables.Add("vBOMInsulationReportSummary")

    End Sub

  End Class

    Private Sub PrintInsulationReportSummary()

        Dim InsulationSummaryReport As CrystalDecisions.CrystalReports.Engine.ReportDocument

        InsulationSummaryReport = New crptInsulationReportSummary

        Try

            CrystalReportsHelper.DatabaseIntializationLion(InsulationSummaryReport)

            InsulationSummaryReport.RecordSelectionFormula = " ({vBOMInsulationReportSummary.head_order_nbr} = 'SDJ120123-17')"

            InsulationSummaryReport.SetDataSource(clsInsulationReportSummary.dsInsulationReportSummary.Tables.Item("vBOMInsulationReportSummary"))

        Catch ex As Exception

            MessageBox.Show("Error Generating Report: StackTrace:" & ex.StackTrace())

        End Try

        Dim CrystalReportViewerForm As New frmCrystalReportViewer

(set break point here)          CrystalReportViewerForm.CrystalReportViewer1.ReportSource = InsulationSummaryReport

        ETIBomBlowerGlobalFunctions.LogReport(InsulationSummaryReport)

        CrystalReportViewerForm.Show() 'With Logging

        InsulationSummaryReport = Nothing

    End Sub

Public Class CrystalReportsHelper

    Shared Function DatabaseIntializationLion(ByRef Rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument) As Boolean

        Dim crtableLogoninfos As New TableLogOnInfos()

        Dim crtableLogoninfo As New TableLogOnInfo()

        Dim crConnectionInfo As New ConnectionInfo()

        Dim CrTables As Tables

        Dim CrTable As Table

        With crConnectionInfo

            .ServerName = "Lion"

            .DatabaseName = "QWright"

            .UserID = "xxxxxxxxxx" (x'd out for security)

            .Password = "xxxxxxxxxx" (x'd out for security)

        End With

        CrTables = Rpt.Database.Tables

        'Loop through each table in the report and apply the

        'LogonInfo information

        For Each CrTable In CrTables

            Select Case CrTable.Name

                Case "vENG_BomGen_LineDetail", _

                     "vENG_BomGen_Costing", _

                     "vENG_BomGen_Costing_Forecast", _

                     "vLineDetailInnerJoinBomGenCosting", _

                     "vLineDetail", _

                     "vCoilAttributes", _

                     "vBOMInsulationReportSummary"

                    crtableLogoninfo = CrTable.LogOnInfo

                    crtableLogoninfo.ConnectionInfo = crConnectionInfo

                    CrTable.ApplyLogOnInfo(crtableLogoninfo)

            End Select

        Next

        Return True

    End Function

CR XI error.jpg (225.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 17, 2012 at 09:16 PM

    The following is weird in your code:

    1)

    InsulationSummaryReport.RecordSelectionFormula = " ({vBOMInsulationReportSummary.head_order_nbr} = 'SDJ120123-17')"

    2)

    CrystalReportsHelper.DatabaseIntializationLion(InsulationSummaryReport) 

                InsulationSummaryReport.RecordSelectionFormula = " ({vBOMInsulationReportSummary.head_order_nbr} = 'SDJ120123-17')"

                InsulationSummaryReport.SetDataSource

    3)

    CrTable.ApplyLogOnInfo(crtableLogoninfo)

    So, as the code runs, it looks like you set a record selection formula before any data is passed to the report. Then you pass in a dataset. Then you logon to a database, thus passing in data from a database.

    Either use a dataset, or a database connection. Once you've decided which, set the selection formula. E.g.; the general flow would be:

    Load report

    Connect to database (via ApplyLogOnInfo or dataset, but not both)

    Apply the selection formula

    View / print / export the report

    - Ludek

    Follow us on Twitter

    Got Enhancement ideas? Try the SAP Idea Place

    Share Your Knowledge in SCN Topic Spaces

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Timothy

      Many thanks. I actually feel quite guilty for not thinking of that issue in the 1st place. It's an old issue that comes up rarely - not sure why it comes up for some unlucky souls and not others. But I'm glad it's working now.

      Happy coding,

      - Ludek