|
-
Feb 1st, 2002, 12:18 PM
#1
Thread Starter
Lively Member
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?
-
Feb 1st, 2002, 12:56 PM
#2
Hyperactive Member
Report.RecordSelectionFormula =
-
Feb 1st, 2002, 01:05 PM
#3
Thread Starter
Lively Member
Where can I put this code?
Where can I put this code?
How can I specify the passed value parameter?
-
Feb 1st, 2002, 01:23 PM
#4
Hyperactive Member
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
Last edited by jcfowl; Feb 1st, 2002 at 01:46 PM.
-
Feb 1st, 2002, 01:40 PM
#5
Thread Starter
Lively Member
Thank you very much JCfowl
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|