Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Providing values to formulas from vb.net

I'm developing my first report (developed with Report Designer) to be fired from vb.net.  I'm running into a problem providing a value to a formula from VB code.  The report was running correctly before I tried to supply the formula value from VB.

The report contains a formula called ShopSuppliesAmount that looks like this at design time:

0

The a report footer section contains the following suppress condition:

{@ShopSuppliesAmount}=0;

The VB code that fires the report looks like this (I'm including code that provides a stored procedure property value, just in case that has anything to do with the problem):

            Dim crParameterField As New ParameterField

            Dim crParameterFields As New ParameterFields

            Dim crParameterDiscreteValue As New ParameterDiscreteValue


            Dim lrptInvoice As New rptInvoice


                    lrptInvoice.DataDefinition.FormulaFields("ShopSuppliesAmount").Text = Chr(39) & mdecShopSuppliesAmount & Chr(39)

                         (Note that the variable mdecShopSuppliesAmount is Decimal, and I'm testing with a value of 0.)

                    crParameterField.Name = "@RepairOrderNumber"

                    crParameterDiscreteValue.Value = miRepairOrderNumber

                    crParameterField.CurrentValues.Add(crParameterDiscreteValue)

                    crParameterFields.Add(crParameterField)

                    crvReport.ParameterFieldInfo = crParameterFields

                    crvReport.ReportSource = lrptInvoice

When I fire the report, I'm getting the following error:

     A string is required here.

     Details:  errorKind

     Error in File temp_(etc...).rpt

     Error in formula Section_Visibility:

     '{ShopSuppliesAmount}=0;'

     A string is required here.

     Details:  errorKind

Can someone tell me what I'm doing wrong?  Thanks!

Former Member
Former Member replied

I've just resolved my problem.  The answer was to remove the single quotes (Chr(39)) from around the numeric variable I was setting the function to.  Instead of this:

     lrptInvoice.DataDefinition.FormulaFields("ShopSuppliesAmount").Text = Chr(39) & mdecShopSuppliesAmount.ToString & Chr(39)

I should have coded this:

     lrptInvoice.DataDefinition.FormulaFields("ShopSuppliesAmount").Text = mdecShopSuppliesAmount.ToString

The report is working perfectly now.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question