Passing variables to Crystal Reports 
Author Message
 Passing variables to Crystal Reports

Does anyone know how to pass variable or value to Crystal Reports Pro from
VB 5 pro?  I need to have the user type in a date range for printing... and
make other run-time choices.

The SelectionFormula and SQLQuery properties (in VB) of the Crystal Report
object have no effect.  I can hard code selection criteria in Crystal
Reports, but as I mentioned, I need to do it at run time.

Any help would be greatly appreciated.

Thanks,

Matt



Thu, 04 Jan 2001 03:00:00 GMT  
 Passing variables to Crystal Reports
Hi Matt!

May be you should use 'parameter fields' ...

Ciao, Carsten.



Fri, 05 Jan 2001 03:00:00 GMT  
 Passing variables to Crystal Reports
Matt:

passing values
    setup a function field in your report...give it a relative name we'll
call it function1
    place the function field where you would want the data to be displayed.

    then from vb...
    crystalreport.formulas(0).text=YourVariable
    crystalreport.printreport

if you only want certain dates to be shown on the report you will have to
modify the sql statement.
in that case just put up an inputbox and capture the dates they want in a
variable then

    crystalreport.sqlquery=modify the where to select a range of dates.

you can't however modify the select portion of the sql statement if you do,
then crystal will overwrite it with its default sql statement.


Quote:
>Does anyone know how to pass variable or value to Crystal Reports Pro from
>VB 5 pro?  I need to have the user type in a date range for printing... and
>make other run-time choices.

>The SelectionFormula and SQLQuery properties (in VB) of the Crystal Report
>object have no effect.  I can hard code selection criteria in Crystal
>Reports, but as I mentioned, I need to do it at run time.

>Any help would be greatly appreciated.

>Thanks,

>Matt



Fri, 05 Jan 2001 03:00:00 GMT  
 Passing variables to Crystal Reports

sorry this is how the passing values should read.
Matt:

passing values
    setup a function field in your report...give it a relative name we'll
call it function1
    place the function field where you would want the data to be displayed.

    then from vb...
    crystalreport.formulas(0).text="function1= " & " ' " & YourVariable & "
' "
    crystalreport.printreport

if you only want certain dates to be shown on the report you will have to
modify the sql statement.
in that case just put up an inputbox and capture the dates they want in a
variable then

    crystalreport.sqlquery=modify the where to select a range of dates.

you can't however modify the select portion of the sql statement if you do,
then crystal will overwrite it with its default sql statement.

Quote:


>>Does anyone know how to pass variable or value to Crystal Reports Pro from
>>VB 5 pro?  I need to have the user type in a date range for printing...
and
>>make other run-time choices.

>>The SelectionFormula and SQLQuery properties (in VB) of the Crystal Report
>>object have no effect.  I can hard code selection criteria in Crystal
>>Reports, but as I mentioned, I need to do it at run time.

>>Any help would be greatly appreciated.

>>Thanks,

>>Matt



Fri, 05 Jan 2001 03:00:00 GMT  
 Passing variables to Crystal Reports
When you define the tables or sql statement in design mode, those fields and
relationships that you define cannot be updated.  However, conditions and
sorting which is after the "where" clause in the sql statement can change.

Therefore:
If your SQL statement in design mode was "select color from colors," and in
run-time you want to see all the colors with "blue" in them, you can do the
folowing code.

dim report as New crystalreport1 (make this global)
dim rs as recordset
dim dbs as database

set dbs = opendatabase(colors.mdb)
set rs = dbs.openrecordset("select color from colors where color like
'*blue*'")
report.database.setdatasource rs
CRViewer1.reportsource = report
CRViewer1.Viewreport

If you tried to do "select color, colorid from colors where color like
'*blue*'", Crystal reports would replace this query with the original SQL, and
you would have all hte colors and no colorid.  So just remember to make sure
your select statement doesn't change.

Hope this helps some poor soul out there.  I know I spent hours figuring this
out.

-Dan Hollingshead

Quote:

> Does anyone know how to pass variable or value to Crystal Reports Pro from
> VB 5 pro?  I need to have the user type in a date range for printing... and
> make other run-time choices.

> The SelectionFormula and SQLQuery properties (in VB) of the Crystal Report
> object have no effect.  I can hard code selection criteria in Crystal
> Reports, but as I mentioned, I need to do it at run time.

> Any help would be greatly appreciated.

> Thanks,

> Matt



Fri, 05 Jan 2001 03:00:00 GMT  
 Passing variables to Crystal Reports
Thanks everyone who volunteered help.

My answer (for anyone interested) lie in the reportsource property for
crystal reports (within vb).  It needed to be set to 3 - crptDataControl and
not
0 - crptReport.

I'm getting the variables at run time and then the report runs from my query
and doesn't look to the file... Yeah, I feel stupid in case you're
wondering.

Matt



Tue, 09 Jan 2001 03:00:00 GMT  
 Passing variables to Crystal Reports
This is easy.

You use the Formulas property - not parameters. Parameters are ignored
when they are run under VB.

For example CrystalReport.Formulas(0) = "125"
Where (0) is the numeric number of the formula (Just count how many
formulas you have until you reach the one you want to change - start at
0) and "125" is the value you want to send to the report. Then simply use
the formula as your parameter throughout the report.

If you are worries about the type - put an example type in the formula.


Simple.



Fri, 12 Jan 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Passing variables to Crystal Report

2. Passing variables to Crystal Reports

3. Passing Variables to Crystal Reports.

4. Passing variables to Crystal Reports.

5. Passing Variable to Crystal Reports

6. passing variables to crystal report from VB6

7. Passing variable into crystal report

8. Passing variables to crystal reports

9. Passing variables to Crystal Reports from ASP

10. Passing variables to Crystal Report

11. Passing Variables to Crystal Reports

12. Passing Variables to Crystal Reports

 

 
Powered by phpBB® Forum Software