Click to See Complete Forum and Search --> : Parameter Using From VB6 to Crystal8


imranctgbd
December 5th, 2004, 03:25 AM
I am a newbye in Crystal Report.

I am using VB6 and Crystal Report v8. I am embedding the report to my Project. But the thing that i cannot do is to pass a parameter to the report. (I can do it by using OCX. But I want to embed the report to the vb project.)

Suppose I want some information on Customer based on country. I am creating a parameter field name {?CountryName} and making SelectionExpert to point to that field to the peremeter. When I open report I see that some dialog come and ask for the Country Name after that It shows the whole.

Now I want to pass the parameter to the report from vb6 without prompting anything.

Please help me to ride out from it.

springsoft
December 5th, 2004, 05:27 PM
using CR ActiveX 8.5 designer Run Time Component (see Project menu, References), which exposes CRAXDRT.

Dim objPrintApp As CRAXDRT.Application
Dim objReport As CRAXDRT.Report

then in your code to print report:
Set objPrintApp = New CRAXDRT.Application
Set objReport = objPrintApp.OpenReport(strReportSourcePath & strSource)

' this example connects to our db2 database, parameters are:
'DriverName,
'ServerName,
'[DatabaseName],
'[UserID],
'[Password],
'[ServerType],
'[pConnectionString]
objPrintApp.LogOnServerEx "p2sodbc.dll", "Server", "Database", "userId", "password"

' This example sets value is first parameter to a Date, because we always
' supply a date as the first parameter.
' You can store your parameter in VB variable and then supply it to report as I
' have done with var named dtepDate..........
If objReport.ParameterFields.Count > 0 Then
objReport.ParameterFields(1).AddCurrentValue dtepDate
End If

objReport.PrintOut


that should help you along the way.
See the file shipped with Crystal, which gives good examples for implementing with either PrintEngine or ActiveX control.
Here's the CR url that explains where to find it:
http://support.businessobjects.com/library/kbase/articles/c2009096.asp

dave