1 Attachment(s)
Passing parameters with vb6 to CR11
I would like to pass some values from VB6 to CR11. Ifound some code posted. I have tried but get the following error. Here is the code I copied from here and the associated error.
VB Code:
Sub RunReport()
Dim crxApp As New CRAXDDRT.Application
Dim crxReport As CRAXDDRT.Report
Dim crxDatabaseTables As CRAXDDRT.DatabaseTables
Dim crxDatabaseTable As CRAXDDRT.DatabaseTable
Dim crxDatabase As CRAXDDRT.Database
Dim crxParm As CRAXDDRT.ParameterValues
Dim crxSubReport As CRAXDDRT.Report
Dim ReportName As String
ReportName = "C:\Consulting\Georgia\Cutbill\Reports\Guide.rpt" 'Report Path
Set crxReport = crxApp.OpenReport(ReportName)
crxReport.ParameterFields.GetItemByName("Door Series").AddCurrentValue (CBDoorCode(CBLI))
crxReport.ParameterFields.GetItemByName("Slat Type").AddCurrentValue CBSlatType(CBLI)
'crxReport.PrintOut False, 1 'uncomment to printout the report
With crView 'Control Name
.ReportSource = crxReport
.ViewReport
While .IsBusy
DoEvents
Wend
.Zoom "75"
.Visible = True
End With
End Sub
Re: Passing parameters with vb6 to CR11
Do you get the error on this line
Set crxReport = crxApp.OpenReport(ReportName)
or this line
.ReportSource = crxReport
Re: Passing parameters with vb6 to CR11
I am guessing these lines present the problem:
VB Code:
crxReport.ParameterFields.GetItemByName("Door Series").AddCurrentValue (CBDoorCode(CBLI))
crxReport.ParameterFields.GetItemByName("Slat Type").AddCurrentValue CBSlatType(CBLI)
is Door Series the actual name of the parameter field in your CR Report? didn't think you could have a space in paramater names.
Re: Passing parameters with vb6 to CR11
Yes I get the error on these two lines
VB Code:
crxReport.ParameterFields.GetItemByName("Quantity").AddCurrentValue (CBQty(CBLI))
crxReport.ParameterFields.GetItemByName("Distributors").AddCurrentValue CBDistributors(CBLI)
I changed the CR11 variables to no spaces I still get the same error. I grap this data from a Query ran on an Access Data base. Not sure whats wrong here.
Bill
Re: Passing parameters with vb6 to CR11
Yeah then it is probably something with your variables.. not sure how you are getting these:
(CBQty(CBLI))
CBDistributors(CBLI)
Re: Passing parameters with vb6 to CR11
They are 2 global variables
VB Code:
Public CBDistributors(20) As String
Public CBQty(20) As Integer
I can look at them they have good values.
Bill
1 Attachment(s)
Re: Passing parameters with vb6 to CR11
Here you can see the values of the 2 variables in the intermediate window
Re: Passing parameters with vb6 to CR11
Could you show me a SS of your CR design screen?
1 Attachment(s)
Re: Passing parameters with vb6 to CR11
Re: Passing parameters with vb6 to CR11
Sorry should have specified this... can you get me a view that has your parameter fields listed?
1 Attachment(s)
Re: Passing parameters with vb6 to CR11
Not sure just what you need to see. Here is the .rpt file
Re: Passing parameters with vb6 to CR11
Ok I think you need to change 2 things... I am assuming that your FormQuery1 is a query in Access? If so I would recommend linking the source directly to the original tables that you need info from. Then use the Select Expert to add in criteria of the data that you would like to see. If you would like to base the criteria on a parameter passed from VB then you will need to add a Parameter field. You can create a Parameter field in the Field Explorer. Paramater fields can be used in the criteria of the Select Expert.
In the code example:
VB Code:
crxReport.ParameterFields.GetItemByName("Quantity").AddCurrentValue (CBQty(CBLI))
crxReport.ParameterFields.GetItemByName("Distributors").AddCurrentValue CBDistributors(CBLI)
Quantity and Distributors would have to be the names of the Parameter fields inside the report and used in the Select Expert to display data based on the parameters that you want to pass.
Hope this helps... once you get it, it will seem easy.