VB.Net report printing is not happy with a sage 300 session created by the program

SUGGESTED

I have a Sage 300 program, developed in VB.Net, that generates crystal report PDFs.

When I run the program from the Sage 300 desktop on my client's server, it works just fine by passing the session token as a parameter.

It also works fine running in Debug mode on my development workstation at my office where it creates the session itself.

When I run it on my client's server from outside of Sage 300 and create my own Sage 300 session the AccpacCOMAPI complains when I try to print the form.  Error follows.

Unhandled Exception: System.Runtime.InteropServices.COMException: Unknown error 0x80040200
at AccpacCOMAPI.IAccpacReport.PrintReport()
at SKUSimpleMakeLabels.Module1.PrintLabels(String& shinum, String truckname) in D:\MyDocuments\Visual Studio 2019\Projects\SKUSimpleMakeLabels\Module1.vb:line 502
at SKUSimpleMakeLabels.Module1.Main() in D:\MyDocuments\Visual Studio 2019\Projects\SKUSimpleMakeLabels\Module1.vb:line 178

Here is my session stuff


mSession.Init("", "AS", "AS9031", My.Settings.ACCPACVERSION)

mSession.Open(My.Settings.SAGEUSER, My.Settings.SAGEPASSWD, My.Settings.ACCPACDB, Today, 0, "")
mDBLinkCmpRW = mSession.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)

And here is my report block

Dim rpt As AccpacCOMAPI.AccpacReport
rpt = mSession.ReportSelect("OEPICK01[" & My.Settings.LABELFORM & "]", " ", " ")
Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup
rptPrintSetup = mSession.GetPrintSetup(" ", " ")
rptPrintSetup.DeviceName = "Brother HL-L2360D series Printe"
rptPrintSetup.OutputName = "TS001"
rptPrintSetup.Orientation = 1
rptPrintSetup.PaperSize = 1
rptPrintSetup.PaperSource = 15
rpt.PrinterSetup(rptPrintSetup)
rpt.SetParam("SELECTBY", "1") ' Report parameter: 2
rpt.SetParam("SORTBY", "0") ' Report parameter: 3
rpt.SetParam("FROMSELECT", shinum) ' Report parameter: 4
rpt.SetParam("TOSELECT", shinum) ' Report parameter: 5
rpt.SetParam("FROMLOC", "1") ' Report parameter: 6
rpt.SetParam("TOLOC", "1") ' Report parameter: 7
rpt.SetParam("PRINTBY", "0") ' Report parameter: 14
rpt.SetParam("SERIALLOTNUMBERS", truckname) ' Report parameter: 15
rpt.SetParam("PRINTKIT", "0") ' Report parameter: 11
rpt.SetParam("PRINTBOM", "0") ' Report parameter: 12
rpt.SetParam("REPRINT", "1") ' Report parameter: 8
rpt.SetParam("QTYDEC", "0") ' Report parameter: 9 - O/E Sales History:Detail,Sort by Item Number
rpt.SetParam("COMPLETED", "1") ' Report parameter: 10
rpt.NumOfCopies = 1
rpt.Destination = AccpacCOMAPI.tagPrintDestinationEnum.PD_FILE
rpt.PrintDir = Labelfolder & UCase(shinum) & ".pdf"
rpt.PrintReport()

In the error message, line 502 refers to the rpt.PrintReport() line

I need this to run from the task scheduler and I have done this before to automate Day-End-Processing and data importing but somehow reporting seems to have different requirements?

Does anything jump out at you?

Thanks

Parents Reply
  • 0 in reply to Jay Converse Acumen

    Thanks Jay

    I copied the dll into my local folder

    That stopped the crashing but now it's not using the export parameters I gave it and it is showing me a printer dialogue Export screen asking me verify that I want to export a PDF file, what I want the file name to be and where to put it.

    I'm trying to have the program be Not interactive.

    Short of developing my forms in something other than crystal, is there another option that yo know of?

Children