Skip to Content
Former Member
Aug 14, 2013 at 04:00 PM

Selection Formula Syntax


I figured that writing a selection formula would be pretty easy but I just can't seem to get the proper syntax.

I am Using VS2012 & CR for .Net

I am building a selection formula in code to ultimately pass to the report for filtering data.

The user will get to choose filtering data from a series of comboboxes and based on those selections I'll build the formula. So attempting to pass just one criteria doesn't work.

Here is what I'm doing (showing relevant code)

In the first combobox the user selects a SKU to filter on in cmbxSKU

dim cboSKU as string = cmbxSKU.Text <== the value of the combobox is 1234

dim myFormula = "{INVEN.SKU} = "" & cboSKU & """ <= Got this syntax directly from the SAP CR Walkthrough & is the same in the SDK Developer guide

I pass myFormula to the frmReport

in the frmReport Load Event I set the characteristic of the viewer including

CrystalReportsViewer1.SelectionFormula = myFormula

However at this point myFormula evaluates to Literally {INVEN.SKU} = " & cboSKU & " as reported by the text visualizer in Intellisense.

When the report runs there are not records showing. (FYI there are plenty records with SKU 1234)

When I force the value of 1234 into the selection formula it works as expected & returns records to report on. that formula looks like this

myFormula = "{INVEN.SKU} = ""1234"""

I have attempted to use the VB syntax of

myFormula = "{INVEN.SKU} = "" ' " & cboSKU & " ' """

and this evaluates to

{INV.SKU} = " '1234' " <=== But this doesn't work

I've replaced the & with the + but no luck

I've reduced the Number of " (Quotes), but no luck.

So now I'm Stuck, What can i do to pass a good & proper selection formula?

Another FYI, I have no selection formula as a part of the base report.