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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 CRXI, Parameter passed but not affecting record set/

Status
Not open for further replies.

mgason

Technical User
Feb 6, 2003
158
AU
Hi,
I have this code that passes 3 parameters to my report. I placed the parameter fields on the report so I can see that they do in fact get passed in.
I have a record selection in my Crystal Report that is based on the 3 parameters, it does not happen.
If I refresh the data, get the parameters dialog in Crystal and enter them manually it succeeds.
Why do the passed parameters not make a selection????

here is my VB6 code
Code:
'set report location
Set report1 = crxApplication1.OpenReport("F:\test.rpt")

'logon
report1.Database.LogOnServer "p2sodbc.dll", "DSN", "database", "user", "password"

'loop through parameters and set
Dim CRXParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim CRXParamDef As CRAXDRT.ParameterFieldDefinition
Set CRXParamDefs = report1.ParameterFields

For Each CRXParamDef In CRXParamDefs
With CRXParamDef
Select Case .ParameterFieldName

  Case "firstParam"
   .ClearCurrentValueAndRange
   .AddCurrentValue CInt(Text1.Text)

  Case "secondParam"
   .ClearCurrentValueAndRange
   .AddCurrentValue "'" & Text2.Text & "'"
    
  Case "thirdParam"
   .ClearCurrentValueAndRange
   .AddCurrentValue "'" & Text3.Text & "'"
  
End Select
End With
Next

report1.EnableParameterPrompting = False

here is my select statement copied from the select expert in CrystalXI, as I said the parameters appear in their fields on the page, so they are getting passed
Code:
{TestList.Job} = {?firstParam} and
{TestList.Company} = {?secondParam} and
{TestList.Project} = {?thirdParam}
 
Hi,
Are you eliminating the possibility of NULL values Or extra spaces being passed ?

To further debug you could add 3 label objects to your form and, in each CASE statement, set the Label's text to the passed parameter , like

Code:
Case "firstParam"
   .ClearCurrentValueAndRange
   .AddCurrentValue CInt(Text1.Text)
    FirstParamLabel.Text = Text1.text
  Case "secondParam"
   .ClearCurrentValueAndRange
   .AddCurrentValue "'" & Text2.Text & "'"
    SecondParamLabel.Text = Text2.text

  Case "thirdParam"
   .ClearCurrentValueAndRange
   .AddCurrentValue "'" & Text3.Text & "'"
    ThirdParamLabel.Text = Text3.text

This will let you see exactly what value is getting assigned .

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I did place the 3 parameter fields on my report page.
They displayed the values from my VB code properly.
Is there any reason a textfield would be better?
thanks mark
 
Hi,
Just to test whether the CASE statements are actually reading the parameter values from those fields...

The Label text does not get assigned until the CASE step executes, so it should confirm that the value in the Text items was correctly handled..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top