T
Tony K
I want to create a report to show information using parameters. I have
setup the report to accept parameters but I want the parameters to come from
a WinForm that shows the same info in a datagridview on a separate WinForm
and not ask the question as the form loads.
Last week, Terry gave me the following code but I'm stupid when it comes to
Crystal Reports.
Private Sub ConfigureCrystalReports()
MyCrystalReportViewer.ReportSource = myReportDocument
Dim myParameterFields As ParameterFields =
MyCrystalReportViewer.ParameterFieldInfo
SetDateRange(myParameterFields,
StartDateTimePicker.Value.ToShortDateString,
StopDateTimePicker.Value.ToShortDateString)
End Sub
Private Sub SetDateRange(ByVal myParameterFields As ParameterFields,
ByVal startDate As String, ByVal
endDate As String)
Dim myParameterRangeValue As ParameterRangeValue = New
ParameterRangeValue()
myParameterRangeValue.StartValue = startDate
myParameterRangeValue.EndValue = endDate
myParameterRangeValue.LowerBoundType = RangeBoundType.BoundInclusive
myParameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive
Dim myParameterField As ParameterField =
myParameterFields("DateRange")
myParameterField.CurrentValues.Clear()
myParameterField.CurrentValues.Add(myParameterRangeValue)
End Sub
*****MY QUERY IS*****(Access DB)
SELECT [Inventory Transactions].TransactionDate, [Inventory
Transactions].TransactionDescription,
[Inventory Transactions].UnitsSold, Products.ProductIDNumber,
Products.ProductDescription, Suppliers.SupplierName
FROM (([Inventory Transactions] INNER JOIN
Products ON [Inventory Transactions].ProductID = Products.ProductID)
INNER JOIN
Suppliers ON Products.SupplierID = Suppliers.SupplierID)
WHERE ([Inventory Transactions].TransactionDate >= ?) AND
([Inventory Transactions].TransactionDate <= ?) AND
([Inventory Transactions].UnitsSold > 0)
ORDER BY Suppliers.SupplierName
How would I set my parameters from my WinForm that has 2 date fields.
Basically, how would I pass any parameters from an existing form to my CR?
My reportViewer is on a NEW form...right? I'm sorry for the stupidity. I
hope you understand. I just don't know how/where I place the above code
that was given to me last week.
Tony K.
setup the report to accept parameters but I want the parameters to come from
a WinForm that shows the same info in a datagridview on a separate WinForm
and not ask the question as the form loads.
Last week, Terry gave me the following code but I'm stupid when it comes to
Crystal Reports.
Private Sub ConfigureCrystalReports()
MyCrystalReportViewer.ReportSource = myReportDocument
Dim myParameterFields As ParameterFields =
MyCrystalReportViewer.ParameterFieldInfo
SetDateRange(myParameterFields,
StartDateTimePicker.Value.ToShortDateString,
StopDateTimePicker.Value.ToShortDateString)
End Sub
Private Sub SetDateRange(ByVal myParameterFields As ParameterFields,
ByVal startDate As String, ByVal
endDate As String)
Dim myParameterRangeValue As ParameterRangeValue = New
ParameterRangeValue()
myParameterRangeValue.StartValue = startDate
myParameterRangeValue.EndValue = endDate
myParameterRangeValue.LowerBoundType = RangeBoundType.BoundInclusive
myParameterRangeValue.UpperBoundType = RangeBoundType.BoundInclusive
Dim myParameterField As ParameterField =
myParameterFields("DateRange")
myParameterField.CurrentValues.Clear()
myParameterField.CurrentValues.Add(myParameterRangeValue)
End Sub
*****MY QUERY IS*****(Access DB)
SELECT [Inventory Transactions].TransactionDate, [Inventory
Transactions].TransactionDescription,
[Inventory Transactions].UnitsSold, Products.ProductIDNumber,
Products.ProductDescription, Suppliers.SupplierName
FROM (([Inventory Transactions] INNER JOIN
Products ON [Inventory Transactions].ProductID = Products.ProductID)
INNER JOIN
Suppliers ON Products.SupplierID = Suppliers.SupplierID)
WHERE ([Inventory Transactions].TransactionDate >= ?) AND
([Inventory Transactions].TransactionDate <= ?) AND
([Inventory Transactions].UnitsSold > 0)
ORDER BY Suppliers.SupplierName
How would I set my parameters from my WinForm that has 2 date fields.
Basically, how would I pass any parameters from an existing form to my CR?
My reportViewer is on a NEW form...right? I'm sorry for the stupidity. I
hope you understand. I just don't know how/where I place the above code
that was given to me last week.
Tony K.