COO in Packing Slip

Hi there,

I am trying to add Country of Origin (COO) on the packing slip and I get to the strangest of errors in SSRS.

So, I added a subreport using the SQL expression:

=“SELECT T1.PartNum, T1.PackNum, T1.PackLine, T1.Calc_CountryISOCode, T1.Calc_CountryDescription, T1.ValuePerc FROM ShipCOO_” + Parameters!TableGuid.Value + " T1 WHERE T1.PackNum = ‘" + cstr(Parameters!Pm_SHIPHEAD_PackNum.Value) + "’ AND T1.PackLine = ‘" + cstr(Parameters!Pm_SHIPDTL_PackLine.Value) + "’"

and the subreport loads fine and prints on the packing slip with no problem.

However, as soon as I add the T1.Primary field on the above SQL expression, to pull the primary COO, I get the “Error: Subreport could not be shown”.

Of course, I made sure that the Primary field is not excluded from the RDD.

Also, when I set the report to print to XML and download the XML, the Primary field is there:

Does anyone have an idea why adding the “Primary” field crushes the subreport?

I just dawned on me. The “Primary” is a special keyword for SQL. So it has to be in brackets. the correct SQL expression is:

=“SELECT T1.PartNum, T1.PackNum, T1.PackLine, T1.Calc_CountryISOCode, T1.Calc_CountryDescription, T1.ValuePerc, T1.[Primary] AS PrimaryCOO FROM ShipCOO_” + Parameters!TableGuid.Value + " T1 WHERE T1.PackNum = ‘" + cstr(Parameters!Pm_SHIPHEAD_PackNum.Value) + "’ AND T1.PackLine = ‘" + cstr(Parameters!Pm_SHIPDTL_PackLine.Value) + "’"

2 Likes