PDA

Click to See Complete Forum and Search --> : problem on passing value


knight_jose
Apr 25th, 2009, 12:36 AM
i have a text box and i want the value on my textbox is place on the my crystal, im new to crystal report.....



Private Sub cmdprint_Click()
Dim oApp As CRAXDRT.Application
Dim oReport As CRAXDRT.Report

Set oApp = New CRAXDRT.Application
Set oReport = oApp.OpenReport(App.Path & "\Reports\other_deduction.rpt", 1)
oReport.Database.SetDataSource dataother.DataSource, 3, 1
oReport.ParameterFields.GetItemByName(oReport.Sections(1).ReportObjects(2).Name).AddCurrentValue "'" & Text1.Text & "'"

frmprintview.CRViewer91.ReportSource = oReport

frmprintview.CRViewer91.ViewReport
frmprintview.Show 1, frmother
End Sub


but it will prompt an error of invalid name...

my crystal report version is 9.2

Online on 8pm to 3am.......philippines time...





making a maze on my head.....

jggtz
Apr 25th, 2009, 02:41 AM
I think it's better using a formula field
Add a formula field to your rpt
Let's say that your formula field name is @MyFormula and the text is :

Trim("Some Text")


Now from your app, it sould be something like

Dim GInt2 As Integer

For GInt2 = 1 To oReport.FormulaFields.Count
Select Case oReport.FormulaFields(GInt2).Name
Case "{@MyFormula}": CRReport.FormulaFields(GInt2).Text = "Trim(" & Chr(39) & Trim(Text1.Text) & Chr(39) & ")"
.
.
End Select
Next GInt2

knight_jose
Apr 25th, 2009, 12:02 PM
i want the value on my textbox get into the crystal report.......

i may not use any of the formula, all i need is to place the value on my textbox on vb6 to then text on my crystal report textbox on the header so that is have a detail information..
the value im going to place on my textbox on crystal report is not in the database?.......................................................

by the way thank reply...

jggtz
Apr 25th, 2009, 06:07 PM
Create a new formula field in CR
Place that formula field in the Header Section instead of the text box
Pass the Text1.Text value from VB app to CR formula field
Try the way I posted in #2
That's how I pass almost all the variable data to CR reports and work ok
Remember that not all CR formula fields return numeric data, that why I use the next as the body of the formula

Trim("Some Text at design time")

and at execution time we can replace that text by other data, in this case the text1. content