Button to run AP Aging from Vendor

SOLVED

I created a button on the Vendor Maintenance screen that runs the AP Aging report.  I pass in the AP Division and Vendor numbers, but I can't get the report to filter by those values.  (Want to run the Aging for the Vendor displayed, like the Sage button does in Customer Maintenance.)

I suspect it is the "Tag$" syntax that is incorrect.  Here is my script:

strSelect = AP_Vendor_bus_APDivisionNo & AP_Vendor_bus_VendorNo
oARReport = oSession.GetObject("AP_AgedInvoiceReport_ui")
Set oARReport = oSession.AsObject(oARReport)

retval = oARReport.SelectReportSetting("STANDARD")
retval = oARReport.SetKeyValue("ReportSetting$","STANDARD")
retval = oARReport.SetKeyValue("RowKey$","1")
retval = oARReport.SetKey()
retVal = oARReport.SetValue("SelectField$", "Vendor Number")
retVal = oARReport.SetValue("SelectFieldValue$", "Vendor Number")
'retVal = oARReport.SetValue("Tag$", "TABLE=AP_Vendor;COLUMN=APDivisionNo$,VendorNo$;")   'incorrect syntax?
retVal = oARReport.SetValue("Tag$", "TABLE=AP_Vendor;COLUMN=APDivisionNo$;")     'tried setting it in 2 lines - no luck
retVal = oARReport.SetValue("Tag$", "TABLE=AP_Vendor;COLUMN=VendorNo$;")
retVal = oARReport.SetValue("Operand$", "=")
retVal = oARReport.SetValue("Value1$", strSelect)
retVal = oARReport.Write

retVal = oARReport.ProcessReport("PREVIEW")
retVal = oSession.DropObject("AP_AgedInvoiceReport_rpt")

Does anyone know what I'm doing wrong?  Thanks!

Hollie

Parents
  • +1
    verified answer

    You need the SetValue on the "KeyReference$" field in addition to several other fields that make up the primary key in SY_ReportSelection.

    These key fields are ModuleCode$+CompanyKey$+ReportID$+ReportSetting$+RowKey$

    So this should work for you.


    sReportSetting = "STANDARD"
    retval = oARReport.SelectReportSetting(sReportSetting)
    retval = oARReport.SetKeyValue("ModuleCode$", oSession.ModuleCode)
    retval = oARReport.SetKeyValue("CompanyKey$", oSession.CompanyKey)
    retval = oARReport.SetKeyValue("ReportID$", oARReport.ReportID)
    retval = oARReport.SetKeyValue("ReportSetting$",s ReportSetting)
    retval = oARReport.SetKeyValue("RowKey$", "00001")
    retval = oARReport.SetKey()
    retVal = oARReport.SetValue("SelectField$", "Vendor Number")
    retVal = oARReport.SetValue("SelectFieldValue$", "Vendor Number")
    retVal = oARReport.SetValue("KeyReference$", "<APDivisionNo$+VendorNo$>") ' Fields must be enclosed in <>.
    retVal = oARReport.SetValue("Tag$", "TABLE=AP_Vendor;")
    retVal = oARReport.SetValue("Operand$", "=")
    retVal = oARReport.SetValue("Value1$", strSelect)
    retVal = oARReport.Write


    If you have criteria on more than one field, you need to repeat the above code again but increment the "RowKey$" value by one.

  • 0 in reply to David Speck

    Thank you!  I believe had it configured this way for a while, and discovered that this works - if the vendor has any open invoices.  However, if the vendor has no open invoices, it does not return the usual "Data is not selected for report printing" message.  It doesn't show anything, so the user will not know there is nothing open.  Is there any way around that?

    This may work - I will check.  

  • +1 in reply to hyanaga
    verified answer

    set the oARReport.LastErrorMsg to "" right before calling ProcessReport. After ProcessReport, if oARReport.LastErrorMsg is not blank and not "0" or if retVal is not 1, then display it to the user. Something like this should work.


    oARReport.LastErrorMsg = ""
    retVal = 0 : retVal = oARReport.ProcessReport("PREVIEW")
    If retVal <> 1 Then oSession.AsObject(oSession.UI).MessageBox "", "Unable to process report." & vbCrLf & "Last Error Msg: " & oARReport.LastErrorMsg


Reply
  • +1 in reply to hyanaga
    verified answer

    set the oARReport.LastErrorMsg to "" right before calling ProcessReport. After ProcessReport, if oARReport.LastErrorMsg is not blank and not "0" or if retVal is not 1, then display it to the user. Something like this should work.


    oARReport.LastErrorMsg = ""
    retVal = 0 : retVal = oARReport.ProcessReport("PREVIEW")
    If retVal <> 1 Then oSession.AsObject(oSession.UI).MessageBox "", "Unable to process report." & vbCrLf & "Last Error Msg: " & oARReport.LastErrorMsg


Children