databand filter from VB.net

HI,


I have a filter on a databand that is linked to a prameter [STIAHD.INV_NUM]== ToDecimal([@INVNUM])

when the user clicks an Invoice in a datagrid on my form, i then set the parameter to the Invoice Number

and the previewcontrol displays ony that Invoice


this works well, however..... I need to display ALL the invoices, if there is no invoice selected in the datagrid

i tried

IIF([@INVNUM]=="","",[STIAHD.INV_NUM]== ToDecimal([@INVNUM]))

in the filter but that didnt work.


is it possible to add and remove the filter on the report databand from my vb.net program at runtime?

or is there a way of ignoring the filter if the parameter is "" or is nothing?


Thanks

Comments

  • i figured this out, (a good nights sleep helped!) so i thought i'd come back and answer my own question.

    maybe it helps someone else in future


     Dim b As DataBand = report1.FindObject("Data1")

     If dgvList.SelectedRows(0).Cells(1).Value.ToString = "Show All" Then

          b.Filter = ""

          report1.SetParameterValue("@Batch", Nothing)

        Else

          b.Filter = "[STIAHD.INV_NUM]== ToDecimal([@Batch])"

          Dim filterValue As String = dgvList.SelectedRows(0).Cells(1).Value

          report1.SetParameterValue("@Batch", filterValue)

        End If

        PreviewControl2.RefreshReport()

  • Hello!

    Your original formula IIF([@INVNUM]==“”, ‘’, ...) didn't work because the DataBand.Filter property must return a boolean, but the “” branch returned a string (which causes a compilation error), plus in C# expressions, IIF evaluates both arguments at once!

    In addition to your working solution involving resetting b.Filter = “” from VB.NET, the same issue can be resolved directly within DataBand.Filter using a correct Boolean condition:

    String.IsNullOrEmpty([INVNUM]) || ([STIAHD.INV_NUM] == ToDecimal([INVNUM]))

    If the parameter is empty, the condition will return true for all rows and display all invoices.

This discussion has been closed.