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

rpt.Setparam failing to transfer parameters to Crystal Reports 2

Status
Not open for further replies.

Boris10

IS-IT--Management
Jan 26, 2012
97
KE
Hi everyone. I am calling a Custom Crystal Report from Accpac macro using Accpac API. I have recorded a macro to get the fill of the code and checked the web for tips on this proceedure. However, after modifying the OERPT.INI and placing my report in the OE60/ENG folder i am still getting the Crystal Reports parameter pop up.
Below is the VB Code
Code:
On Error GoTo ACCPACErrorHandler
Dim report As String
report = "\\MCLERPSTORE\A4w\OE60A\ENG\MCL_SALES_INVOICE_FORM.rpt"

' TODO: To increase efficiency, comment out any unused DB links.
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)

Dim rpt As AccpacCOMAPI.AccpacReport
Set rpt = ReportSelect(report, "      ", "      ")
Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup
Set rptPrintSetup = GetPrintSetup("      ", "      ")
rptPrintSetup.DeviceName = "\\SALES-PC\HP LaserJet 3055 PCL"
rptPrintSetup.OutputName = "DOT4_001"
rptPrintSetup.Orientation = 1
rptPrintSetup.PaperSize = 1
rptPrintSetup.PaperSource = 15
rpt.PrinterSetup rptPrintSetup
rpt.SetParam "INVNUMBER", "IN12000001"   ' Report parameter: 6
rpt.NumOfCopies = 1
rpt.Destination = PD_PREVIEW
rpt.PrintDir = report
rpt.PrintReport

Exit Sub
Below is the modified part of the .ini file
Code:
'************** Object id = Custom Invoice Report******************
'
[MCL_SALES_INVOICE_FORM]
heading=29150
crystal=MCL_SALES_INVOICE_FORM
orientation=portrait
paper size=1
optparams=1
2=INVNUMBER         STRING  29155

Could anyone help me to figure out why i am getting the Crystal pop-ups.

Kind regards
Boris
 
You don't need the parameter in OERPT.INI, remove that section you added.

Change your rpt.SetParam to

rpt.SetParam "@SELECTION_CRITERIA", "{OEINVH.INVNUMBER} = ""IN12000001
 
Hi Ettienne, thank you for a quick reply. It worked beautifully!

So when do you actually need to edit the .INI and why? Would you have any tips on that one.

 
Only if rpt.SetParam "@SELECTION_CRITERIA" does not work for you - which I've never run into.
 
Ettienne's solution is far more powerful but you're getting the popups, I suspect, because your section doesn't start with the two letters of the module.

Typically you'll have:
Code:
Set rpt = ReportSelect("OEMCL_SALES_INVOICE_FORM", "      ", "      ")

Your .ini section would read
Code:
[OEMCL_SALES_INVOICE_FORM]

But go with Ettienne's suggestion because you can be smarter about building the selection criteria than Crystal. e.g. If your report asks for a range of customers but the user selects blanks to ZZZZZZZZZZ then don't add any filter on the customer number to your @SELECTION_CRITERIA. But if you have two parameters for FromCustomer and ToCustomer then Crystal will ask the database for all customers IDCUST >= '' AND IDCUST <= 'ZZZZZZZZZZ' - and there's no point. You're asking the database to do extra work. Same if the user asks for a single customer. Change the filter to IDCUST='1200' instead of having Crystal use two parameters and generate IDCUST >= '1200' AND IDCUST <= '1200'. Yes - the database optimizer should pick that up but it might not.
 
Thank you DjangMan, it makes a lot of sense.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top