Click to See Complete Forum and Search --> : passing parameter to crystal


Nasty2
October 16th, 2005, 08:56 AM
Hey,
I have an application developed with Visual basic 6 and Crystal Reports 9.
I am trying to pass a parameter to a crystal report and just can't seem to get it right.
I am opening the report (the report opens well but loads the saved data in the report) with the following code:
Module1.OpenDatabase

Dim s_myNumber As String
s_myNumber = Me.txtPurchaseOrderNumber.Text

Dim s_sql As String
sql = "...............WHERE 'POR_PURCHASE_ORDERS'.'ORDER_NUMBER'='" & s_myNumber & "'"

Dim rst As New ADODB.Recordset
rst.Open sql, conn

If Not (rst.EOF) Then
Dim myReport As New CrystalReport1
myReport.Database.SetDataSource (rst)

Dim frm As New Form2
frm.Show
frm.CRViewer91.Refresh
frm.CRViewer91.ReportSource = myReport
frm.CRViewer91.ViewReport
End If
Screen.MousePointer = vbNormal

The parameter "OrderNo" is set to "equal to 0000033960" in the report. What I want to do is pass my own parameter from VB6 and I do not want the pop-up screen that asks for the parameter value to show.

Hope you can help
Thanks

boumerlin
October 16th, 2005, 08:00 PM
Hi,

I haven't actually programmed against Crystal by passing the recordset object. I didn't realize that was possible.

Assuming you can just pass the recordset and it will read everything including your parameters, have you tried removing the parameter from the report in the report designer?

Usually there is an API for setting parameters programmatically. It looks like you're programming agains the RDC object model!?! I know there is a parameter API for that. If the above doesn't work, you might want to check the Business Object site for sample RDC code

Anyway.......don't know how helpful I am. Good luck!

Linda

Madhi
October 22nd, 2005, 09:07 AM
You need to define Parameter collection variable and assign the value to it and also set EnablePopupMenu property to False in your coding