vision21
February 12th, 2000, 08:44 PM
Hi,
Can someone please tell me how to assign the reportselectionfomula during VB runtime.
I need to assign 2 variable in the fomular, that is >= Variable1 and <= Variable 2.
Thank you.
February 14th, 2000, 12:13 AM
Select by variable
CrystalReport1.ReportFileName = App.Path & "\Custom\inventory for product.rpt"
If cboModel.Text <> "" Then
CrystalReport1.SelectionFormula = "{Inventory.ProdModel} = '" & cboModel.Text & "'"
End If
CrystalReport1.Action = 1
CrystalReport1.SelectionFormula = ""
Select by term
Make a Table with two filds Date1 and Date2, then put those two fields on your report. Before you call that report in run time update the table with date.
Date1 = txtFromDate.Text
Date2 = txtToDate.Text
CrystalReport1.ReportFileName = App.Path & "\Custom\Purchase Invoices by Term.rpt"
CrystalReport1.SelectionFormula = "{PURCHASE INVOICE.PrchDate}" _
& "In Date(" & Year(Date1) & ", " & Month(Date1) & ", " & Day(Date1) & ")" _
& "To Date(" & Year(Date2) & ", " & Month(Date2) & ", " & Day(Date2) & ")"
CrystalReport1.Action = 1
CrystalReport1.SelectionFormula = ""
February 14th, 2000, 05:15 AM
just do
crystral.selectionformula="{Query.whatever}>=" & variable1 & " And {Query.whatever}<=" & variable2
If you're dealing with dates put in the single quotes as you would in an sql string