Problem with VB passing parameters to Crystal Report - Stored Procedure 
Author Message
 Problem with VB passing parameters to Crystal Report - Stored Procedure

 I have a Crystal 8 report which uses a stored procedure for its data. The
stored procedure has 3 parameters, so I need to pass values from VB to the
report at run time, but I cannot get it to work.
For formula passing, we use the following code:

Function SetFormula(Report As CRPEAuto.Report, ByVal formulaName As String,
ByVal value As Variant)
Dim formulas As CRPEAuto.FormulaFieldDefinitions
Dim formula As CRPEAuto.FormulaFieldDefinition

Set formulas = Report.FormulaFields

For i = 1 To formulas.Count
Set formula = formulas(i)

...
formula.Text = Format(value)

I cloned this and changed "formula" to "parameter", but it will not do
"parameter.text = value" or "parameter.SetCurrentValue 101". For the second
one it gives an erorr message that the value (101) is not in the enum list.
I have looked in Helps but cannot find anything on this subject.

The manual "Version 8.5 Developer's Guide" (I am using version 8), on page
83 gives Dim's like this:

Dim CRXParamDefs as CRAXDRT.ParameterFieldDefinitions

Dim CRXParamDef as CRAXDRT.ParameterFieldDefinition

However, I cannot find out what object CRAXDRT is. I tried a Report object,
but that did not work. I looked for CRAXDRT in Help but found nothing.

Does anyone have a piece of actual code they could send me by email which
shows how to set the parameters to the report?

Thanks in advance.

Marvin



Mon, 28 Jun 2004 03:08:21 GMT  
 Problem with VB passing parameters to Crystal Report - Stored Procedure
I'm using the following snippet :

    For Each prm In Report.ParameterFields
        prm.ClearCurrentValueAndRange
        Select Case prm.Name

                prm.AddCurrentValue CLng(Prosit.Projet_pk)

                ' Feed...

                ' Feed...
            Case Else
                MsgBox "Paramtre d'tat " & prm.Name & " non gr.",
vbExclamation
        End Select
    Next

Bascially I browse the parameters and I use a particular variable in my app
to provide a value for this parameter based on its name...

Formulas are likely the formula calculated inside the report from your
database fields...



Quote:
> I have a Crystal 8 report which uses a stored procedure for its data. The
> stored procedure has 3 parameters, so I need to pass values from VB to the
> report at run time, but I cannot get it to work.
> For formula passing, we use the following code:

> Function SetFormula(Report As CRPEAuto.Report, ByVal formulaName As
String,
> ByVal value As Variant)
> Dim formulas As CRPEAuto.FormulaFieldDefinitions
> Dim formula As CRPEAuto.FormulaFieldDefinition

> Set formulas = Report.FormulaFields

> For i = 1 To formulas.Count
> Set formula = formulas(i)

> ...
> formula.Text = Format(value)

> I cloned this and changed "formula" to "parameter", but it will not do
> "parameter.text = value" or "parameter.SetCurrentValue 101". For the
second
> one it gives an erorr message that the value (101) is not in the enum
list.
> I have looked in Helps but cannot find anything on this subject.

> The manual "Version 8.5 Developer's Guide" (I am using version 8), on page
> 83 gives Dim's like this:

> Dim CRXParamDefs as CRAXDRT.ParameterFieldDefinitions

> Dim CRXParamDef as CRAXDRT.ParameterFieldDefinition

> However, I cannot find out what object CRAXDRT is. I tried a Report
object,
> but that did not work. I looked for CRAXDRT in Help but found nothing.

> Does anyone have a piece of actual code they could send me by email which
> shows how to set the parameters to the report?

> Thanks in advance.

> Marvin



Mon, 28 Jun 2004 17:41:41 GMT  
 Problem with VB passing parameters to Crystal Report - Stored Procedure
Thank you, but I am still having trouble.  I am using VB 6 and Crystal
Reports 8.0 on Windows 2000.  I get as error
the "object doesn't support this property of method"
on this line "Parameter.AddCurrentValue Format(value)",.

Do you have Report defined diffferently or do you see some other difference?
My object also does not support "parameter.ClearCurrentValueAndRange".
It seems that my object Parameter is not the same as your prm.

At the top of my routine is the following:

Function SetParameter(Report As CRPEAuto.Report,  _
        ByVal ParameterName As String, ByVal value As Variant)
    Dim Parameters As CRPEAuto.ParameterFieldDefinitions
    Dim Parameter As CRPEAuto.ParameterFieldDefinition

Then I have the following:

'ParameterName comes from the calling code and is different for each report
'    Set Parameters = Report.ParameterFields

    For Each Parameter In Report.ParameterFields
        valueType = Parameter.valueType
        If LCase(Parameter.Name) = ParameterName Then
            valueType = Parameter.valueType
            If valueType >= 1 And valueType <= 8 Then
                Parameter.AddCurrentValue Format(value)


Quote:
> I'm using the following snippet :

>     For Each prm In Report.ParameterFields
>         prm.ClearCurrentValueAndRange
>         Select Case prm.Name

>                 prm.AddCurrentValue CLng(Prosit.Projet_pk)

>                 ' Feed...

>                 ' Feed...
>             Case Else
>                 MsgBox "Paramtre d'tat " & prm.Name & " non gr.",
> vbExclamation
>         End Select
>     Next

> Bascially I browse the parameters and I use a particular variable in my
app
> to provide a value for this parameter based on its name...

> Formulas are likely the formula calculated inside the report from your
> database fields...



> > I have a Crystal 8 report which uses a stored procedure for its data.
The
> > stored procedure has 3 parameters, so I need to pass values from VB to
the
> > report at run time, but I cannot get it to work.
> > For formula passing, we use the following code:

> > Function SetFormula(Report As CRPEAuto.Report, ByVal formulaName As
> String,
> > ByVal value As Variant)
> > Dim formulas As CRPEAuto.FormulaFieldDefinitions
> > Dim formula As CRPEAuto.FormulaFieldDefinition

> > Set formulas = Report.FormulaFields

> > For i = 1 To formulas.Count
> > Set formula = formulas(i)

> > ...
> > formula.Text = Format(value)

> > I cloned this and changed "formula" to "parameter", but it will not do
> > "parameter.text = value" or "parameter.SetCurrentValue 101". For the
> second
> > one it gives an erorr message that the value (101) is not in the enum
> list.
> > I have looked in Helps but cannot find anything on this subject.

> > The manual "Version 8.5 Developer's Guide" (I am using version 8), on
page
> > 83 gives Dim's like this:

> > Dim CRXParamDefs as CRAXDRT.ParameterFieldDefinitions

> > Dim CRXParamDef as CRAXDRT.ParameterFieldDefinition

> > However, I cannot find out what object CRAXDRT is. I tried a Report
> object,
> > but that did not work. I looked for CRAXDRT in Help but found nothing.

> > Does anyone have a piece of actual code they could send me by email
which
> > shows how to set the parameters to the report?

> > Thanks in advance.

> > Marvin



Tue, 29 Jun 2004 01:16:09 GMT  
 Problem with VB passing parameters to Crystal Report - Stored Procedure
I now have this working.
Thanks.


Quote:
> Thank you, but I am still having trouble.  I am using VB 6 and Crystal
> Reports 8.0 on Windows 2000.  I get as error
> the "object doesn't support this property of method"
> on this line "Parameter.AddCurrentValue Format(value)",.

> Do you have Report defined diffferently or do you see some other
difference?
> My object also does not support "parameter.ClearCurrentValueAndRange".
> It seems that my object Parameter is not the same as your prm.

> At the top of my routine is the following:

> Function SetParameter(Report As CRPEAuto.Report,  _
>         ByVal ParameterName As String, ByVal value As Variant)
>     Dim Parameters As CRPEAuto.ParameterFieldDefinitions
>     Dim Parameter As CRPEAuto.ParameterFieldDefinition

> Then I have the following:

> 'ParameterName comes from the calling code and is different for each
report
> '    Set Parameters = Report.ParameterFields

>     For Each Parameter In Report.ParameterFields
>         valueType = Parameter.valueType
>         If LCase(Parameter.Name) = ParameterName Then
>             valueType = Parameter.valueType
>             If valueType >= 1 And valueType <= 8 Then
>                 Parameter.AddCurrentValue Format(value)



> > I'm using the following snippet :

> >     For Each prm In Report.ParameterFields
> >         prm.ClearCurrentValueAndRange
> >         Select Case prm.Name

> >                 prm.AddCurrentValue CLng(Prosit.Projet_pk)

> >                 ' Feed...

> >                 ' Feed...
> >             Case Else
> >                 MsgBox "Paramtre d'tat " & prm.Name & " non gr.",
> > vbExclamation
> >         End Select
> >     Next

> > Bascially I browse the parameters and I use a particular variable in my
> app
> > to provide a value for this parameter based on its name...

> > Formulas are likely the formula calculated inside the report from your
> > database fields...



> > > I have a Crystal 8 report which uses a stored procedure for its data.
> The
> > > stored procedure has 3 parameters, so I need to pass values from VB to
> the
> > > report at run time, but I cannot get it to work.
> > > For formula passing, we use the following code:

> > > Function SetFormula(Report As CRPEAuto.Report, ByVal formulaName As
> > String,
> > > ByVal value As Variant)
> > > Dim formulas As CRPEAuto.FormulaFieldDefinitions
> > > Dim formula As CRPEAuto.FormulaFieldDefinition

> > > Set formulas = Report.FormulaFields

> > > For i = 1 To formulas.Count
> > > Set formula = formulas(i)

> > > ...
> > > formula.Text = Format(value)

> > > I cloned this and changed "formula" to "parameter", but it will not do
> > > "parameter.text = value" or "parameter.SetCurrentValue 101". For the
> > second
> > > one it gives an erorr message that the value (101) is not in the enum
> > list.
> > > I have looked in Helps but cannot find anything on this subject.

> > > The manual "Version 8.5 Developer's Guide" (I am using version 8), on
> page
> > > 83 gives Dim's like this:

> > > Dim CRXParamDefs as CRAXDRT.ParameterFieldDefinitions

> > > Dim CRXParamDef as CRAXDRT.ParameterFieldDefinition

> > > However, I cannot find out what object CRAXDRT is. I tried a Report
> > object,
> > > but that did not work. I looked for CRAXDRT in Help but found nothing.

> > > Does anyone have a piece of actual code they could send me by email
> which
> > > shows how to set the parameters to the report?

> > > Thanks in advance.

> > > Marvin



Tue, 29 Jun 2004 04:19:59 GMT  
 Problem with VB passing parameters to Crystal Report - Stored Procedure
I have had some issues with Crystal 8 and stored procedures also.  The other
piece of the puzzle that got thrown in for me is that I am using a UDL file
for connectivity.

Although this solution adds a little work, it worked for me:
I rewrote my app to call the stored procedure from VB.  That way I had more
control and could debug easier.  The stored proc returns a recordset.  That
recordset gets passed to the report this way:

            CrxRpt.DiscardSavedData
            CrxRpt.Database.SetDataSource rs, 3, 1
            CrxRpt.ReadRecords

This allowed me to have a RPT file for formatting only.  This may not be the
answer for you, but it worked in my situation.

In order to keep track of the stored procedure used, I just created a text
file (or xml file) to associate the RPT file to the stored procedure and
what paramaters are needed.

Good luck.

Quote:
> I have a Crystal 8 report which uses a stored procedure for its data. The
> stored procedure has 3 parameters, so I need to pass values from VB to the
> report at run time, but I cannot get it to work.
> For formula passing, we use the following code:

> Function SetFormula(Report As CRPEAuto.Report, ByVal formulaName As
String,
> ByVal value As Variant)
> Dim formulas As CRPEAuto.FormulaFieldDefinitions
> Dim formula As CRPEAuto.FormulaFieldDefinition

> Set formulas = Report.FormulaFields

> For i = 1 To formulas.Count
> Set formula = formulas(i)

> ...
> formula.Text = Format(value)

> I cloned this and changed "formula" to "parameter", but it will not do
> "parameter.text = value" or "parameter.SetCurrentValue 101". For the
second
> one it gives an erorr message that the value (101) is not in the enum
list.
> I have looked in Helps but cannot find anything on this subject.

> The manual "Version 8.5 Developer's Guide" (I am using version 8), on page
> 83 gives Dim's like this:

> Dim CRXParamDefs as CRAXDRT.ParameterFieldDefinitions

> Dim CRXParamDef as CRAXDRT.ParameterFieldDefinition

> However, I cannot find out what object CRAXDRT is. I tried a Report
object,
> but that did not work. I looked for CRAXDRT in Help but found nothing.

> Does anyone have a piece of actual code they could send me by email which
> shows how to set the parameters to the report?

> Thanks in advance.

> Marvin



Mon, 05 Jul 2004 07:08:35 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. passing Parameter from Vb to Stored Procedure In crystal reports

2. Passing Parameters to Crystal Report 5.0 (Stored Procedure Query )

3. Passing Stored Procedure parameters via VB6 into Crystal Report (ver 8)

4. Passing parameter from Crystal OCX to a report that uses a stored procedure

5. Pass parameter to a MS SQL stored procedure from Crystal Report 6.0

6. VB.NET,SQL SERVER 2000 STORED PROCEDURE PARAMETERS, CRYSTAL REPORTS

7. Passing Stored Procedures from VB to Crystal Reports 8

8. Crystal 8.5 - troubles with passing strings as stored procedure parameters

9. Passing Stored Procedure Parameter by Crystal RDC 7

10. Passing Stored Procedures Parameters to Crystal (6)

11. Crystal - passing parameters to SQL stored procedure

12. Passing Parameters into a sub report's stored procedure

 

 
Powered by phpBB® Forum Software