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

Parameter Passing Does Not Work.....

Status
Not open for further replies.

sane79

MIS
Nov 18, 2003
60
SG
Hi experts.. This is urgent....
Pls help.. :(

I'm trying to pass a parameter from VB6 into Crystal Report 8.5

Below is my code.. Currently, My Crystal report is still prompting me with the window whenever I call my report...

Is there a way to disable the crystal report prompt and to take in whatever the user selects in the VB program?

With CrystalReport1
.ReportFileName = App.Path & "\picklistreport.rpt"
.Connect = "C:\POS\Data"
.DiscardSavedData = True
.RetrieveDataFiles
.ReportSource = 0
.SQLQuery = "SELECT * FROM ORDI WHERE Exists (SELECT PO_NO FROM ORDM WHERE PO_ID = '" & tmpPOID & "' AND BCODE = '" & tmpbcode & "') AND PO_ID = '" & tmpPOID & "'"
.Destination = crptToWindow
.PrintFileType = crptCrystal
.WindowState = crptMaximized
.WindowMaxButton = False
.WindowMinButton = False
'.SelectionFormula = "{ORDI.PO_ID} = '" & tmpPOID & "'"
.SelectionFormula = "{ORDM.BCODE} = '" & tmpBranch & "'"

.Action = 1
End With
 
Where are you trying in your code to pass the parameter? I don't see any reference to a parameter field object in your code. Try downloading the sample vb apps at the Crystal Decision website. They will point you in the right direction:


By the way, setting the SQLQuery property is not a recommended technique. I would recommend using an ADO recordset instead, since it looks like you want to define your query at runtime. The link above will have references to using an ADO recordset.
 
FV Trainer: Thanks!
I managed to get the parameter passing to work..
But now I have antoher problem..
Over in crystal report, I'm not able to display the fields that are related to the 2 paramters that are passed over..

What happens is I need to select from the dbf tables, all the records that are related to the 2 parameters..

Can u advise me on how I should do it other than using stored procedure?


Below is my workable parameter passing code:
============================================

Set creApp = New CRPEAuto.Application
Set CreRpt = creApp.OpenReport(App.Path & "\PICKLISTREPORT.rpt")
Set rptDB = CreRpt.Database
Set rptTbls = rptDB.Tables
Set rptTbl = rptTbls.Item(1)

Set creParaFldDefs = CreRpt.ParameterFields
Set crePara = creParaFldDefs.Item(1)
crePara.SetCurrentValue (tmpbcode)

Set crePara = creParaFldDefs.Item(2)
crePara.SetCurrentValue (tmpPOID)

rptTbl.SetPrivateData 3, rs

'CreRpt.Preview

============================================


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top