Skip to Content
avatar image
Former Member

Crystal 10 for VS 2005 - How to bound unbound fields at runtime


In VB6 I have unbound fields and method SetUnboundFieldDataSource to bound those fields at runtime, but in VS 2005 there is no way to handle unbound fields?

I have desktop application, some CR report with unbound fields 1,2,3.

At runtime I want to set CR,datasource to DataTable and to bound unbound fields 1,2,3 to DataTable fields 1,2,3. How to do this?

Thanks in advance

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 12, 2010 at 03:28 PM

    Create three formulas; formula1,formula2, formula3. Populate those formulas with your data. One formula example;

    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim Report As New CrystalReport1()
    Dim FormulaFields As FormulaFieldDefinitions
    Dim FormulaField As FormulaFieldDefinition
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    FormulaFields = Report.DataDefinition.FormulaFields
    FormulaField = FormulaFields.Item(0)
    FormulaField.Text = "[formula text]"
    CrystalReportViewer1.ReportSource = Report
    End Sub


    Follow us on Twitter

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 13, 2010 at 06:38 AM

    Thank you Ludek,

    I understand this part with formulas.

    FormulaField = FormulaFields.Item(0)

    FormulaField.Text = "[formula text]"

    But how to do this:

    I have DataTable with 3 columns: ID, Name, Email

    I want at runtime to bound like this:

    FormulaFields.Item(0). datasource = dt.columns["ID"]

    FormulaFields.Item(1). datasource = dt.columns["Name"]

    FormulaFields.Item(2). datasource = dt.columns["Email"]

    How to do this, in VB6 there is method like this:

    Report.Database.SetDataSource Rs

    Report.AutoSetUnboundFieldSource crBMTName

    or like this:

    Dim fld As FieldObject

    Set fld = Report.Sections("D").ReportObjects(1)

    fld.SetUnboundFieldSource "{Customer.Customer ID}"

    Add comment
    10|10000 characters needed characters exceeded