Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009

    Unanswered: retrieving a value from Crystal formula field

    this would seem to be quite simple, but i cannot retrieve anything but null/blank values from Crystal formula fields.
    in this instance, the crystal report is wrapped inside VB6 using crystal viewer.
    through VB code i can locate formula fields by item number and by name
    but the .value property yields nothing.
    The code below is baffling to me...the text of the formula is available but not
    the value.
    is this even possible?

    Private Sub getValue(crxReport As Object)
    Dim crxFormula As CRAXDRT.FormulaFieldDefinitions
    Dim X As String
    Dim I As Integer

    Set crxFormula = crxReport.FormulaFields
    For I = 1 To crxFormula.Count
    If crxFormula(I).Name = "{@patient_name}" Then
    X = crxFormula(I).Value
    MsgBox I & ") " & X & " " & crxFormula(I).Text
    End If
    Next I

    Set crxFormula = Nothing

    End Sub

  2. #2
    Join Date
    Jan 2003
    British Columbia
    When are you calling the GetValue procedure?

    Formulas are typically evaluated for each record in the report. If you call GetValue after the report is generated, there would be no record/data to use.

    You need to call the GetValue procedure while the report is being generated.
    Option Explicit
    Private crApp As CRAXDRT.Application
    Private crRep As CRAXDRT.Report
    Private WithEvents crDetails As CRAXDRT.Section
    Private Sub Form_Load()
        Set crApp = New CRAXDRT.Application
    End Sub
    Private Sub Command1_Click()
        Set crRep = crApp.OpenReport("C:\Report1.rpt")
        Set crDetails = crRep.Sections("D")
        Me.CRViewer1.ReportSource = crRep
    End Sub
    Private Sub crDetails_format(ByVal pFormattingInfo As Object)
    End Sub

  3. #3
    Join Date
    Sep 2009
    makes sense, i'll give it a try. thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts