Click to See Complete Forum and Search --> : Passing a VB string to a Crystal parameter field


Andy99
March 12th, 2004, 04:23 PM
Hello,
I'm having trouble passing a VB string to a Crystal Report parameter field. Following is an excerpt of the code:
--------------------------------------------------
strDocID = InputBox("Please enter the DocID")

If strDocID <> "" Then
With CrystalReport1
.ReportFileName = "C:\Program Files\CSC Imaging\CSCReports\Reports\DocumentHistory.rpt" .Connect = cn.ConnectionString
.WindowState = crptMaximized
strSelection = "{CSC_TRANS.Document_ID} = " & "'" + strDocID + "'"
.ReplaceSelectionFormula strSelection
.Destination = crptToWindow
.Action = 1
---------------------------------------------------

The user enters the DocID, but when the Crystal Report launches, the user has to enter it again.

Following is the entry in the Record Selection Formula:
{CSC_TRANS.Document_ID} = {?DocumentID_PROMPT}

Also, if they select Cancel in the Crystal parameter window, it still tries to run the report. How can I stop the report from running?

Thank you for your assistance!
Andy

jasie24
March 15th, 2004, 05:45 AM
either is wrong the formula,and is crystal report,doesn't know the field. or...
work with an report object,and put
Public reportApp As CRAXDRT.Application
Public Report As CRAXDRT.Report

reportApp=createobject("CRAXDRT.Application")
report=reportApp.loadReport("....rpt")
...for not showing parameter prompting
Report.EnableParameterPrompting=false
report is an object of craxdrt.dll i thing at least i have worked with this one.this is for not showing the parameters inputs again.
also,it should be existing in the report(in design) a parameter(Insert/Parameter) and the value for that should have your docID value
something like this.
Dim cpars As CRAXDRT.ParameterFieldDefinitions
Dim cpar As CRAXDRT.ParameterFieldDefinition
Set cpar = cpars(1)
cpar.AddCurrentValue (docID)
docID here is your VB variable

Maybe this will work,or try to verify carefully the selection formula,AND in report it should be existing a parameter that will take in the code that value!

Good luck

Andy99
March 16th, 2004, 07:46 PM
Thank you very much for the reply, jasie24!