Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass multiple parameters to Crystal Reports from VB.NET

Status
Not open for further replies.

davepruce

Programmer
Dec 18, 2001
17
0
0
GB
Hi

I have built a VB.NET app (in VS2003) that does (successfully) various things with SQL2000 tables and I'd like it to also do some reporting on these table.
The system revolves around us (an auto engineering company) receiving pallets containing a number of returned items from customers that are faulty.
It books in the pallet to a table called (surprisingly) Pallets, and the contents to a table called Pumps. We have other tables with Dealer and Customer data on that is relevant to this app.
I've built a couple of reports using Crystal Reports and am now extending them to allow selection by parameters.
Initially, a single parameter is fine to simply select a pallet and report the Dealer/Pallet/Pumps details in a nice elegant fashion.
I can even make it select 2 separate parameters to select by Pallet and Fault type.
Now I want the user to be able to enter all sorts of parameters on one form, then pass them all to the CR and do the record selection in there.
This is what stumps me. How do I pass the results of textboxes and pulldown selections to Crystal Reports, I dont seem to be able to 'see' any fields created in VB once I am in CR.
Any and all help gratefully received.

Thanks
 
Dave

If all you're doing is filtering data, why dont you do this in your SQL Stored Procedures. Its possible to develop stored procedures with parameters to generate a dynamic where clause, which to me is far simpler than anything in CR



Sweep
...if it works dont mess with it
 
Sweep
Thanks for the comments, however......you obviously know your way around all this stuff, I've just written my first VB anything app in .NET and am trying vainly to integrate a Crystal Report as previously stated.
Can you point me at a web resource that would show me how to use a stored procedure as input to a Crystal Report.
Incidentally, I still need the user to select values for the different parameters!
Thanks
Dave
 
This is an example of passing parameters to crystal. Very simple report selecting orders. The parameters are the
CustomerNo(string) and order date range. all of text boxes on the input form. The report is "test2Report.rpt"

Private Sub bRunReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bRunReport.Click
Dim ReportDocument As test2Report
Dim ParameterFields As ParameterFields
Dim ParameterValues As ParameterValues

'Create an instance of the report
ReportDocument = New test2Report

'Connect to Viewer
CrystalReportViewer1.ReportSource = ReportDocument

'Get the Parameters collection from the Viewer
ParameterFields = CrystalReportViewer1.ParameterFieldInfo

'Get CustomerId parameter
Dim CustIdFld As ParameterField = ParameterFields.Item("CustomerId")

'set up ParameterValues to hold the value to pass to the viewer before execution
ParameterValues = CustIdFld.CurrentValues

Dim CustId As ParameterDiscreteValue = New ParameterDiscreteValue
CustId.Value = tbCustNo.Text
CustIdFld.CurrentValues.Add(CustId)
ParameterValues.Add(CustId)

'Get OrdserDateRange
Dim OrderdatesFld As ParameterField = ParameterFields.Item("OrderDateRange")

ParameterValues = OrderdatesFld.CurrentValues

Dim OrderDateRangeValue = New ParameterRangeValue
'the dates will be inclusive
With OrderDateRangeValue
.EndValue = CType(tbHighDate.Text, Date)
.LowerBoundType = RangeBoundType.BoundInclusive
.StartValue = CType(tbLowDate.Text, Date)
.UpperBoundType = RangeBoundType.BoundInclusive
End With

ParameterValues.Add(OrderDateRangeValue)
CrystalReportViewer1.ParameterFieldInfo = ParameterFields

End Sub

 
I can't seem to simply create a parameterfields using Dim ParameterFields As ParameterFields

Am I missing something fundamently basic?

my code:

Sub Open_CrystalViewer_STD(ByVal ReportName As String, ByVal StartPeriod As Date, ByVal EndPeriod As Date)
MsgBox(CDate(StartPeriod) & " To " & CDate(EndPeriod))
Dim paramField As ParameterFields
Dim ViewRpt As New FRM_ViewReport

ViewRpt.CrystalReportViewer().ReportSource = ReportName
ViewRpt.Show()
End Sub

underlines the ParameterFields in blue to suggest it doesn't understand.

Do I have to import the CrystalDecisions.Shared module somehow its listed in the references in the solution.

Thanks in advance
 
Dim paramFields As New CrystalDecisions.Shared.ParameterFields
Dim paramField As New CrystalDecisions.Shared.ParameterField
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top