Passing a parameter to Crystal Reports using a button script

SUGGESTED

Hi All,

    I have created a new report that is launched from a button script.  I have one thing left to accomplish & the syntax is killing me.   Several things to get "out of the way", this is being done is Sage 2015 Premium.  What we have wound up doing is installing the client for 4.50 on the workstations so the "old" runtimes are available.   There is an existing report that works fine.  This report works fine except I need to pass a parameter (not a report selection - it will be used as a secondary filter and for display)    The report finds items that are in the same "category" (a udf).  The Parameter will be used to display the item code that the report was being called from (It runs from a line on a sales Order) as well as filter the records to items were the cost is within a percentage of the cost of the called item.

The error that I get is Expected identifier.    I have to say that I wish there was something that explained how to format the variables when using them, it is a constant issue for me.. 

All that out of the way, here is the script:

Dim App, RptFile, RptWindow, User, Comp, Pw, Dest, RptSelect, RptSelect1, RptSelect2
Dim Rept, Login, ExportOpt, DSNstring, DBOpt
User = "ads"
Comp = MAS_SCR_CMP
PW = "Acutedata8!"

'Report File: Change to the full path and file name
RptFile = "\\mas02\Sage\Sage 100 Premium ERP\MAS90\Reports\AltItemsCUSTOM.rpt"

'Destination Print or Preview, set it to 1 for Print and 0 to Preview
Dest = 0

'Report Selection
RptSelect = _
"{CI_Item.UDF_PROD_CATEGORY} = '"+SO_SalesOrderDetail_bus_UDF_PROD_CATEGORY+"'"

'RptSelect1 = ("SO_SalesOrderDetail_bus_ItemCode$")
'RptSelect2 = ("SO_SalesOrderDetail_bus_UDF_PROD_CATEGORY$")

'Set objShell = CreateObject("WScript.Shell") 'not needed for SQL database nlr/dsd '12/22/15
'RegLocate = "HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\SOTAMAS90\" 'not needed for SQL 'database nlr/dsd 12/22/15
'objShell.RegWrite RegLocate & "UID", User not needed for SQL database nlr/dsd '12/22/15
'objShell.RegWrite RegLocate & "PWD", PW 'not needed for SQL database nlr/dsd 12/22/15
'objShell.RegWrite RegLocate & "COMPANY", Comp 'not needed for SQL database nlr/dsd '12/22/15
'Set objShell = Nothing 'not needed for SQL database nlr/dsd 12/22/15

Set App = CreateObject("CrystalRuntime.Application")
'Login = App.LogOnServerEx("p2sodbc.dll", "SOTAMAS90") 'not needed for SQL database nlr/dsd 12/22/15

Set Rept = App.OpenReport (RptFile)

Rept.ParameterFields.Item(1).(""&SO_SalesOrderDetail_bus_ItemCode&"")  'THIS IS THE PROBLEM LINE

Set ExportOpt = Rept.ExportOptions
Set DBOpt = Rept.Database

ExportOpt.FormatType = 31
ExportOpt.DestinationType = 1
ExportOpt.PDFExportAllPages = True
ExportOpt.DiskFileName = "\\mas02\Sage\Sage 100 Premium ERP\MAS90\Reports\AltItem_" & MAS_SCR_USR & ".pdf"

If Not Isnull(RptSelect) then
Rept.RecordSelectionFormula = RptSelect
'else
End if

RptWindow = "Alternate Item Report"

if Dest = 1 then
Rept.PrintOut
else
Rept.Export False
end if

Dim SH
PDF = ""
Set SH = CreateObject("WScript.Shell")
PDF = "\\mas02\Sage\Sage 100 Premium ERP\MAS90\Reports\AltItem_" & MAS_SCR_USR & ".pdf"
'retVal = oScript.DebugPrint(PDF)
SH.Run(Chr(34) & PDF & chr(34))
Set SH = Nothing