I am using Crystal Report 5 with Visual Basic 6. I like a use select a data from Visual Basic Screen and list value in the VB report, based on the selection. How can I pass a parameter to Crystal Report 5 from Visual Basic Screen?
I am using Crystal Report 5 with Visual Basic 6. I like a use select a data from Visual Basic Screen and list value in the VB report, based on the selection. How can I pass a parameter to Crystal Report 5 from Visual Basic Screen?
Report.RecordSelectionFormula =
Where can I put this code?
How can I specify the passed value parameter?
This is an example i use in one of my programs.
Most of the code has to do with calculating the formula
all you need is to put that Report.ReportSelectionFormula =
into the formload event on your form that displays the
report.
VB Code:
Dim Report As New CrystalReport1 Private Sub Form_Load() Screen.MousePointer = vbHourglass '***************** Get Date from List and Reorder for Year/Month/Day ************ Dim TheDate, strYear, strMonth, strDay, CrystalParameter As String Dim Index As Integer Dim numYear, numMonth, numDay TheDate = "" CrystalParameter = "{dtcelluse.dteDate} = date(" Index = 0 Do While Index < Reports.List1.ListCount If Reports.List1.Selected(Index) Then numYear = Year(Reports.List1.List(Index)) numMonth = Month(Reports.List1.List(Index)) numDay = Day(Reports.List1.List(Index)) If TheDate <> "" Then TheDate = TheDate & " OR " & CrystalParameter & numYear & "," & numMonth & "," & numDay & ")" Else TheDate = CrystalParameter & numYear & "," & numMonth & "," & numDay & ")" End If End If Index = Index + 1 Loop 'Here is the Important Stuff Report.DiscardSavedData 'Gets rid of REFRESH problem Report.RecordSelectionFormula = TheDate 'Gives Selection Parameter CRViewer1.ReportSource = Report CRViewer1.ViewReport Screen.MousePointer = vbDefault End Sub
Thank you very much JCfowl