If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Crystal Reports > retrieving a value from Crystal formula field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-09-09, 20:22
mtr3693 mtr3693 is offline
Registered User
 
Join Date: Sep 2009
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 09-10-09, 13:32
brucevde brucevde is offline
Registered User
 
Join Date: Jan 2003
Location: British Columbia
Posts: 44
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.
Code:
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
    Me.CRViewer1.ViewReport
    
End Sub

Private Sub crDetails_format(ByVal pFormattingInfo As Object)
    GetValue
End Sub
Reply With Quote
  #3 (permalink)  
Old 09-12-09, 08:30
mtr3693 mtr3693 is offline
Registered User
 
Join Date: Sep 2009
Posts: 2
makes sense, i'll give it a try. thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On