Home > Net >  Dynamic Formula in Crystal Report Formula with winform
Dynamic Formula in Crystal Report Formula with winform

Time:05-29

I using Visual studio.

I have SQL table tbInvoice: amount1, amount2, invNumber.

In winform, i have checkbox1, checkbox2.

If checkbox1 is checked, then in CR should be @total = amount1.

If checkbox1 and checkedbox2 is checked, then in CR should be @total = amount1 amount2

My formula to print :
frmInv.CrystalReportViewer1.SelectionFormula = "{tbInvoice.invNumber} = '" & FrmInvoice.txtInvNo.Text & "'"

How i accomplish this?

How formula @total in CR can read if checkbox is checked in winform?

I need something like this in CR @total:

if frmInvoice.checkbox1.checked = true and frmInvoice.checkbox2.checked = false then {tbInvoice.amount1}

elseif frmInvoice.checkbox1.checked = true and frmInvoice.checkbox2.checked = true then {tbInvoice.amount1} {tbInvoice.amount2}

endif

Pls Help. Thank You

CodePudding user response:

  1. Add a parameter to the report.
  2. The formula logic can depend on the parameter.
  3. Your code can set the parameter value.

CodePudding user response:

I didn't understand your last question but here is an example for the {@YourValue} formula:

IF {?Your_Parameter} = "ABC" Then {tbInvoice.amount1} ELSE {tbInvoice.amount1}   {tbInvoice.amount2}

Then, simply SUM that formula at whatever level(s) you need.

Your code needs to set the parameter value.

  • Related