I am using VB to Export a Crystal Report (9) to a PDF. I pass many Parameter values to the Report, but because I have formulas based on Sum and Grouping and stuff across sub reports, I need to pull a Formula Fields Value from the report and stick it somewhere in my VB app, such as a variable. Any Ideas?

Some of the code that I use:

Code:
Public Sub BuildReportsByClient(ClientXID As String, StartDate As String, EndDate As String)

Dim CrystalRpt As String, CrystalRptPath As String, CrystalRptPushPath As String   '// Report Information
Dim InvLossAmt As Currency, UnbillAmt As Currency '// Parameter values to pass to report
Dim i As Integer, Cn As New ADODB.Connection, Cn2 As New ADODB.Connection, Rs As New ADODB.Recordset, sSQL As String  '// Database usage
Dim oReport As CRAXDRT.Report, crxApplication As CRAXDRT.Application, crxExportOptions As CRAXDRT.ExportOptions '// Crystal Report tools
Dim RptFileName As String, NumClients As Integer, CRAmount As Currency, LeaseAmt As Currency, RefNo As String
Dim ExtAmt As String

Set crxApplication = New CRAXDRT.Application  '// create a new instance of the RAS application

CrystalRptPath = GetReportPath("Option B")  '// get the path of the report to use

'//Create the log file for AR and AP postings
Dim LogFile As String

LogFile = App.Path & "\" & CStr(Replace(Date, "/", "") & Replace(Time, ":", "") & "OptionBLog.rtf")

Cn.Open "Driver={SQL Server};" & _
              "Server=yyyy;" & _
              "Database=yyy;" & _
              "Uid=sa;" & _
              "Pwd="

Cn2.Open "Driver={SQL Server};" & _
              "Server=xxxx;" & _
              "Database=xxx;" & _
              "Uid=sa;" & _
              "Pwd="
  
  Do Until FTPDone = True
    DoEvents 'wait for file to upload
  Loop

  '// Build the File Name
  RptFileName = Replace(ClientXID, " X", "")
  RptFileName = Replace(CStr(RptFileName & Date & Time), "/", "")
  RptFileName = Replace(RptFileName, ":", "")
  RptFileName = Replace(RptFileName, " ", "")
  
  Label1 = "Preparing Report " & RptFileName & ".pdf"

  '//Create the Statement
  CrystalRptPushPath = GetReportPushPath("Option B") & "\" & RptFileName & ".pdf" '// get the path to push the pdf to
  FileToDelete = CrystalRptPushPath
  
  ExtAmt = CStr(GetExtAmt(ClientXID, StartDate, EndDate))
  RefNo = Left(RptFileName, 10)
  
  Set oReport = crxApplication.OpenReport(CrystalRptPath, 1)  '// open the Crystal Report
  
  oReport.ParameterFields.Item(1).AddCurrentValue CStr(UCase(Trim(ClientXID)))     '// pass the Client X ID to the report
  oReport.ParameterFields.Item(2).AddCurrentValue CDate(StartDate)  '// pass the Start Date to the report
  oReport.ParameterFields.Item(3).AddCurrentValue CDate(EndDate)      '// pass the End Date to the report
  oReport.ParameterFields.Item(4).AddCurrentValue RefNo      '// pass the End Date to the report

  Set crxExportOptions = oReport.ExportOptions
  crxExportOptions.DestinationType = crEDTDiskFile
  crxExportOptions.DiskFileName = CrystalRptPushPath
  crxExportOptions.FormatType = crEFTPortableDocFormat
  crxExportOptions.PDFFirstPageNumber = 1
  crxExportOptions.PDFLastPageNumber = 1
  crxExportOptions.PDFExportAllPages = True
  
  oReport.Export False
 
  Label1 = "Connecting to Web Server to transfer file " & RptFileName & ".pdf"
  FtpPut CrystalRptPushPath, RptFileName & ".pdf"
  
  sSQL = "EXEC a Stored Procedure Here"
  
  Cn2.Execute sSQL
  
  With Me
    If .ProgressBar1.Value < .ProgressBar1.Max Then
      .ProgressBar1.Value = .ProgressBar1.Value + 1
    End If
  End With

If Rs.State <> 0 Then Rs.Close
If Cn.State <> 0 Then Cn.Close
If Cn2.State <> 0 Then Cn2.Close

Set Rs = Nothing
Set Cn = Nothing
Set Cn2 = Nothing
Set oReport = Nothing
Set crxApplication = Nothing
Set crxExportOptions = Nothing

Label1 = "Processing Complete!"

End Sub