PO Receipt of Goods Received Quantity not writing

SOLVED

Hi All,

I'm hoping I'm making a simple mistake in my coding and someone can help me out.  Below is a snippet of code where I'm reading serial numbers and importing into Receipt of Goods Entry (with an invoice number, in case it matters).

I'm looping through all the lines on the PO/Receipt to find the line with the matching item and quantity that needs to be received in (from a CSV) file.  That appears to be working.  However, I'm finding that the received quantity does not get written (or perhaps the line is not saved) except for one item where we happen to just have a receipt quantity of just 1 (with 1 serial number).  The lines with multiple serial numbers and even the lines for items that are not serialized (standard cost valuation) are also not getting saved.  I'm receiving no errors at any point.  Also, I have a pop up after the nWriteLine to confirm that the code reaches that line.

Please note that I have removed error checking for legibility here:

********************************************************************

retVal = oPOLines.nMoveFirst()

do until oPOLines.nEOF or strFlag = "Y"

retVal = oPOLines.nSetValue("QuantityReceived", QuantityReceived) 'THIS IS THE FIELD I'M LOOKING TO UPDATE

'add serial number number to distribution
if strValuation = "6" then

if trim(strSerialNumbers) <> "" then 'parse the serial number and place in array (comma delimted)
arrSerialNos = splitLine(strSerialNumbers) 'this is parsing out the serial  numbers via a sub routine not shown here

count = 0

'loop through array containing serial numbers and distribute
for each item in arrSerialNos
strSerialNo = arrSerialNos(Count)
retVal = oDistribution.nAddDistributionLine(strSerialNo) 'this sets the serial number
retVal = oDistribution.nSetValue("QuantityReceived", 1) 'always 1 for serial nos

retVal = oDistribution.nWrite()

retVal = oDistribution.nCommitRow()

count = count + 1
Next

end if

end if 'end add serial number to distribution

'write the line
retVal = oPOLines.nWrite()

msgbox "writing line: " & QuantityReceived & " of item " & strItem & " for serial number " & strSerialNumbers & vbcrlf & "PO Item: " & strPOItem & vbcrlf & "PO Qty: " & QuantityOrdered

retVal = oPOLines.nMoveNext()
Loop

retval = oPOHeader.nWrite()