sending value in VB to Formula in Crystal Report 8.5
holla...
wrong room perhaps... but pls help... since I know this room will reply faster that other.... and I need this help soon.
I have a .RPT file which have an empty formula.
if you ask why empty formula ? coz, I'll send a value to this empty formula from my VB project.
PS : only 1 formula exist in that .RPT file
let's say this empty formula name = "period"
and I have a text box object, name = "txtPeriod"
what i need to do is to send txtPeriod.Text (in VB) to formula "{period}" in Crystal Report.
I did as below, but error.....
VB Code:
Dim CApp As New CRAXDRT.Application
Dim CReport As CRAXDRT.Report
Dim myPeriode as String
Screen.MousePointer = vbHourglass
Set CReport = CApp.OpenReport(App.Path & "\myReport.rpt")
CReport.DiscardSavedData
CReport.PrinterSetup (0)
myPeriode = "As Of : " & Format(cDate(txtPeriod.Text), "mmm-yyyy")
'error occured at below line
CReport.FormulaFields(1).Value = myPeriode
any help ?
pls...
thx a lot,
[-w-]
Re: sending value in VB to Formula in Crystal Report 8.5
:p
huehuehue...
thx a lot to brucevde and pasvorto... :)
both are work for me.
but I still confuse... why .value can't be used ?
and if I use .text without inserting => """", why does it not workin ?
(no error, but not workin too)...
e.g : (yesterday, i've tried below)
VB Code:
objReport.FormulaFields(1).Text = "AS of : " & Format(Date, "mmm/yyyy") & ""
when I tried to debug, objReport.FormulaFields(1).Text value is "As of : Dec-2004", but in my Rpt files, no changes at all...
why is that ?
I guess this is my last Question to both of u for this case. :)
btw, thanks a lot again....
it works
[-w-]
Re: sending value in VB to Formula in Crystal Report 8.5
Quote:
and if I use .text without inserting => """", why does it not workin ?
(no error, but not workin too)...
You should be getting an error when you print or preview the report.
Quote:
but in my Rpt files, no changes at all...
This is a runtime change. The changes are dropped when the report object is set to nothing. I have never checked, is there a Save method on the report object.
Re: sending value in VB to Formula in Crystal Report 8.5
You can do this many different way.
You could create a parameter in CR and use the parameters collection in vb to pass the parameter to CR.
You could create an ADO recordset with the SQL containing the date filter. Then set the recordset as the .Recordsource for the report.
Or the parameter could be used in the CR formula. Then pass the parameter to CR.
...