PDA

Click to See Complete Forum and Search --> : Passing Parameters from vb to crystal report


rathi
Sep 22nd, 2000, 09:51 AM
Hi,

Can any one help with passing parameters from vb program to crystal reports.

Example:

Crystal report displays the Customer details from NWind.mdb.
I want to pass the parameter, CustomerID = XYZ.


Any help would be greatly appreciated.

Thank you.

Rathi

cautious
Sep 27th, 2000, 04:00 AM
The following should work
CrystalReport1.SelectionFormula = "{CustomerID} = 'xyz'"

Set CrystalReport1.SelectionFormula = "" at end of program or else the report will hold the last Selection Formula

Hope this helps
Mick

[Edited by cautious on 09-27-2000 at 05:05 AM]

KWell
Sep 27th, 2000, 04:17 AM
Sorry Cautious, but SelectionFormula is the where clause of the SQL and Rahi ask for parameters (for changing this you must use CrystalReport1.ReplaceSelectionFormula = "{CustomerID} = 'xyz'")

For passing parameters, you must use this code

' Syntax : CrystalReport1.ParameterFields(ArrayIndex)="ParameterName;
NewValue;SetCurrentValue"
' Where :
' ArrayIndex is an index from 0 to the number of parameters to pass (there is no link between parametername and the index number)
' ParameterName is the name of the parameter in the crystal report (case sensitive)
' NewValue is the new value to put to the parameter
' SetCurrentValue is equal to "TRUE" or "FALSE"
' TRUE : the parameter value is passed to the current value in the report; the user is not prompted to enter the parameter value.
' FALSE: the parameter value is passed to the default value for the parameter; the user is prompted to enter the parameter value, with the value you set showing as the default value.
CrystalReport1.ParameterFields(0)="CustomerID;xyz;TRUE"


[Edited by kwell on 09-27-2000 at 05:27 AM]

rathi
Sep 27th, 2000, 06:25 AM
Originally posted by KWell
Sorry Cautious, but SelectionFormula is the where clause of the SQL and Rahi ask for parameters (for changing this you must use CrystalReport1.ReplaceSelectionFormula = "{CustomerID} = 'xyz'")

For passing parameters, you must use this code

' Syntax : CrystalReport1.ParameterFields(ArrayIndex)="ParameterName;
NewValue;SetCurrentValue"
' Where :
' ArrayIndex is an index from 0 to the number of parameters to pass (there is no link between parametername and the index number)
' ParameterName is the name of the parameter in the crystal report (case sensitive)
' NewValue is the new value to put to the parameter
' SetCurrentValue is equal to "TRUE" or "FALSE"
' TRUE : the parameter value is passed to the current value in the report; the user is not prompted to enter the parameter value.
' FALSE: the parameter value is passed to the default value for the parameter; the user is prompted to enter the parameter value, with the value you set showing as the default value.
CrystalReport1.ParameterFields(0)="CustomerID;xyz;TRUE"


[Edited by kwell on 09-27-2000 at 05:27 AM]


Hi Friends,

Thanks for your support.

I'm going to use your suggestions, hope I can come back if I have any difficulties.

Thanks again.

Rathi

rathi
Sep 28th, 2000, 04:33 AM
[QUOTE]Originally posted by rathi
[B][QUOTE]Originally posted by KWell
[B]Sorry Cautious, but SelectionFormula is the where clause of the SQL and Rahi ask for parameters (for changing this you must use CrystalReport1.ReplaceSelectionFormula = "{CustomerID} = 'xyz'")

For passing parameters, you must use this code

' Syntax : CrystalReport1.ParameterFields(ArrayIndex)="ParameterName;
NewValue;SetCurrentValue"
' Where :
' ArrayIndex is an index from 0 to the number of parameters to pass (there is no link between parametername and the index number)
' ParameterName is the name of the parameter in the crystal report (case sensitive)
' NewValue is the new value to put to the parameter
' SetCurrentValue is equal to "TRUE" or "FALSE"
' TRUE : the parameter value is passed to the current value in the report; the user is not prompted to enter the parameter value.
' FALSE: the parameter value is passed to the default value for the parameter; the user is prompted to enter the parameter value, with the value you set showing as the default value.
CrystalReport1.ParameterFields(0)="CustomerID;xyz;TRUE"


[Edited by rathi on 09-28-2000 at 05:35 AM]