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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass parametr from vb to crystal 1

Status
Not open for further replies.

simma

Programmer
Sep 11, 2001
398
0
0
US
Hello
Can anyone please give me the syntax to pass the parameter from vb to crystal reports 8.
Thanks
 
I have not played with RDC. When I have done Crystal from VB, it was through the OCX. In that scenerio, I used Crystal Formulas other collections to override the settings that were in the RPT file.
 
Thanks
But I need syntax somthing like
Crep.parameterfields(0)=...
I could only get so far..
Thanks
 
I too have used the Crystal OCX with VB6. Not sure about all the differences with the RDC. Here's how it works with the OCX
Add a Crystal Report (CrystalReport1) control to your form.

With CrystalReport1
.Connect = "DSN=REPORT;UID=Jack;PWD=1Fju5j9;DSQ=YOURDB"
.SelectionFormula = ""
'Reset all formulas
.Formulas(0) = ""
.Formulas(1) = ""
.Formulas(2) = ""
.Formulas(3) = ""
.Formulas(4) = ""
.Formulas(5) = ""
'Define parameters for your report formulas
.Formulas(0) = _
"StartDate= Date (" & Format(dtpBDate, "yyyy") _
& "," & Format(dtpBDate, "mm") _
& "," & Format(dtpBDate, "dd") & ")"
.Formulas(1) = _
"EndDate= Date (" & Format(dtpEDate, "yyyy") _
& "," & Format(dtpEDate, "mm") _
& "," & Format(dtpEDate, "dd") & ")"
.Formulas(2) = "Line= " & mintLine & ""
.Formulas(3) = "Shift= '" & mstrShift & "'"
.Formulas(4) = "DTType= '" & mstrType & "'"
.Formulas(5) = "WorkOrder= '" & mstrWorkOrder & "'"
.ReportFileName = strReportFile
.WindowTitle = strReportDesc
End With

A good getting started resource for Crystal/RDC resousces is
Hope this helps.
 
Which database are you working with? If it's SQL Server or Oracle, the better way to pass parameter is stored procedure.
 
Hi, I've made this to make it more easy. You just send the report, the name of the parameter (it is key sensitive), the value you want to set and the type of the parameter.
It cycles through the parameters collection untill it finds the one you are passing.

Claudia



Sub SetearParametrosReporte(Cr As CRAXDRT.Report, _
nombreparam As String, _
valor As Variant, _
Optional TipoDato As String = "STR")
Dim CRXParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim CRXParamDef As CRAXDRT.ParameterFieldDefinition

Set CRXParamDefs = Cr.ParameterFields
'This code cycles through the ParameterFieldDefinitions collection in the main report.

For Each CRXParamDef In CRXParamDefs
With CRXParamDef
Select Case .ParameterFieldName

'It finds and sets the appropriate Crystal parameter.

Case "MainParam"
.SetCurrentValue "Main Report Parameter"
'Now it finds and sets the appropriate stored procedure parameter.

Case nombreparam
Select Case TipoDato
Case "STR"
.SetCurrentValue valor
Case "DATE"
If IsNull(valor) Then
.SetCurrentValue CDate("01/01/1970")
Else
.SetCurrentValue CDate(valor)
End If
Case "INT"
.SetCurrentValue CLng(valor)
Case "BOOL"
.SetCurrentValue CBool(valor)
End Select
End Select
End With
Next

'Finally, it disables parameter prompting so the user won't be prompted for a value.

Cr.EnableParameterPrompting = False


End Sub
 
Thanks you so much all of you..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top