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!

how to pass parameters to crystal reports from vb

Status
Not open for further replies.

jagannadh

Technical User
Aug 1, 2008
1
0
0
IN
Help with passing parameters to crystal reports using vb please. I know it might be simple but i am a amateur to this.
Thanks for the solution before hand;)

 
Try something like this:

Report.ParameterFields(1).AddCurrentValue (sClient)
Report.ParameterFields(3).AddCurrentValue (txtCodeVar.Text)
Report.ParameterFields(4).AddCurrentValue (dteFromTo(0).Value)
Report.ParameterFields(5).AddCurrentValue (dteFromTo(1).Value)


Oli
 
or try this:

Dim oRpt as New CrystalReport1

oRpt.RecordSelectFormula = "{Emp.city} = 'Anytown'"

*********************
oRpt is the Report Document
CrystalReport1 is the Crystal Report Designer
"{Emp.city} is the Crystal Report syntax
 
You could enumerate the parameters like this:

(Create the application object and open the report before you do this)

Dim crxParameter As craxdrt.ParameterFieldDefinition
Dim nCounter As Integer
Dim sParam as string

For nCounter = 1 To crxRpt.ParameterFields.Count
'pick off each parameter one by one
Set crxParameter = crxRpt.ParameterFields.Item(nCounter)
'get the parameter name
sParam = crxParameter.ParameterFieldName
'check the parameter name
Select Case UCase$(Trim$(sParam))
Case "USER"
crxParameter.AddCurrentValue sUser
Case "PERIOD", "PER"
crxParameter.AddCurrentValue sPeriod
End Select
Set crxParameter = Nothing
Next

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top