Script no longer works when previously worked before.

Hi I am very green to Sage scripting and am having an issue with a script that previously worked but no longer works now.

I borrowed this code from and old post and this script was working for a bit. The textbox would appear with the Item code and after playing with it the button suddenly stopped working with no error code to it. It stopped working when I was deleting and adding rows to see if it would work.

I am running this under the IM_TRANSACTION panel, I am not sure if that helps.

strTemp = ""
Set oLines = oBusObj.AsObject(oBusObj.Lines)

retVal = oLines.MoveFirst()

Do While Not(cBool(oLines.EOF))
    retVal = oLines.GetValue("ItemCode$", strTemp)
    retVal = oSession.AsObject(oSession.UI).MessageBox(strTemp)
    retVal = oLines.MoveNext()
Loop