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!

Calling report in Visual Basic

Status
Not open for further replies.

homer661

Programmer
May 11, 2001
9
0
0
US
I can get a Crystal Report to pull up in Visual Basic, but the variables I set in Crystal Reports are not prompted for when using Visual Basic. How do I set up the user interface to have the client machines be prompted to put in the parameters I set?

Or do have to resort to letting the Visual Basic interface do all the work? We got this to work fine, but it would be so much easier if we can just let the Crystal Reports variables work on their own.

Is it possible to force the built-in Crystal parameters to prompt when using Visual Basic to call a report?
 
They should prompt automatically.
Do you have the reports saved with data? That will prevent the prompts. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Hello

if you are referring to parameters in crystal reports not prompting the user, here is some information that should deem helpful in this situation.


Changes the default value of the specified parameter field. When the prompting dialog box appears for the parameter field, the value you specify with this property is the value you are prompted with.

Usage

[form.]Report.ParameterFields(ArrayIndex)[=ParameterName;
NewValue;SetCurrentValue]

Remarks

The parameter, SetCurrentValue can either be set to TRUE or FALSE.

If set to TRUE, the parameter value is passed to the current value in the report; the user is not prompted to enter the parameter value.

If set to 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.

The default value for SetCurrentValue is FALSE.

This property does not eliminate the prompt by specifying a current value for the parameter field. You will still be prompted but the default value in the prompt will be the value you specify.

Use a separate line of code for each parameter field for which you want to change the value.

The order of values in the array must conform to the order of parameter fields in the report.

The first parameter field in the report is array index (0), the second is (1), etc.

For example, to change the value of the first parameter field in a report (parameter1) to red use the following syntax (user will not be prompted to enter a value):

CrystalReport1.ParameterFields(0) = parameter1;red;TRUE

Or, to prompt the user to change the value of the third parameter field in a report (parameter3) use the following syntax (user will be prompted to use the default value set using the NewValue parameter below - blue):

CrystalReport1.ParameterFields(2) = parameter3;blue;FALSE

For Parameter fields in the subreport, simply refer the next available array number for the ParameterField propertyand refer to the name of the parameter and send in the value. The following is an example of useage:

Main report has a parameter field called: Title Subreport1 has a parameter field called: Details Subreport2 has 2 parameter fields called: Country and Area
In VB, sample code as follows:
CrystalReport1.ParameterFields(0)="Title; Call Volume Report; true" CrystalReport1.ParameterFields(1)="Details; Transactions Today; true" CrystalReport1.ParameterFields(2)="Country; United States; true" CrystalReport1.ParameterFields(3)="Area; OH; true"

hope this helps.
Please let me know if you need further help on this or if I have assumed wrong on the situation.

E. McEvoy
Crystal Reports Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top