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

    Just an update on this as another project revealed some important details regarding the "KeyReference$" and "Tag$" values that need to be set. 

    When dealing with a multi-part key, like AP_Vendor, you must set the "KeyReference$" like I did in the original example.

    For a single-part key, like CI_Item, you can set "KeyReference$" to "" (blank).

    The "Tag$" value should always contain the "Table=" and either "Column=" for single-part keys or "KeyReference=" for multi-part keys with the fields enclosed in "<" and ">".

    The "Tag$" for a single-part key should look like this.


    retVal = oARReport.SetValue("Tag$", "TABLE=CI_Item;COLUMN=ItemCode$")


    The "Tag$" for a multi-part key should look like this.


    retVal = oARReport.SetValue("Tag$", "TABLE=AP_Vendor;KEYREFERENCE=<APDivisionNo$+VendorNo$>;")


  • 0 in reply to David Speck

    Hey David,

    Using this code, does this work with just a Sage 100 install, or does the Crystal Reports application need to be

    installed on the pc running the report.

Reply Children