Wednesday, March 28, 2012

Parameter passing CR 10 from VB6

Hi,

I am having problems passing multiple parameters to a CR10 report through VB6 and SQL 2000 sp's.

I think that my vb syntax for passing the parameters is incorrect because:

1. I can call the reports fine within crystal reports
2. The stored procedures return the correct values using parameter passing in Query Analyzer
3. When I set EnableParameterPrompting = True in my VB code the report shows up fine when the parameters are entered through the Crystal parameter dialog box. However, this gives the user free text options to enter what ever they like.

The report accepts four parameters and I get a "Failed to open rowset 22007 - Syntax error converting datetime from character string".

All of my parameter values are set to be strings and this error is not making any sense to me.

Any help would be appreciated.

Thanks,

b1. The ERR in question is related to the Conversion from Date to String variable,
which I presume you have to correct it and store to a variable (strkey1)

Set crystal = New CRAXDRT.Application 'MANAGES REPORTS
Set Report = crystal.OpenReport(a) 'OPEN OUR REPORT - 'a' is the name
of your report with FULL PATH.
Report.DiscardSavedData
Report.Database.SetDataSource rsBldo ' rsBldo is the recordset
containing the Data.
Report.EnableParameterPrompting = False
Report.EnableSelectDistinctRecords = True
Report.EnableGeneratingDataForHiddenObject = False
Report.ParameterFields(j).ClearCurrentValueAndRange

// strkey1 is the variable which holds the above string variable
// Mandatorily you have to create a Parameter Field in CR.

Report.ParameterFields(1).AddCurrentValue (strkey1)

THIS I USES IN CR 9.2 and NOT CR 10, pls try out, hope it should work.

No comments:

Post a Comment