UDT eof error

I'm getting an error stating "Error 20 Syntax Error.  Program: SY_Commonui.pvc" when I loop through a UDT using a button script.  Perhaps I have a typo or other mistake here.  It appears to be crashing on the eof check (highlighted in green).  Any ideas where I've goofed?

Thanks!

oUDT = oSession.GetObject("CM_UDTMaint_bus", "SO_UDT_Phantom_Kits")

if oUDT = 0 then 'run if user has permission to access UDT (oUDT would be zero if insufficient permissions)

else 'continue if user has permissions

Set oUDT = oScript.AsObject(oUDT)

retVal = oUDT.SetBrowseFilter(sPhantom) 

retval = oUDT.MoveFirst() 'start looping through ALL UDT records to search for this phantom item

Do While Not(CBool(oUDT.EOF)) 'appears to error here

retval = oUDT.GetValue("UDF_Phantom_Kit$", sPhantomCheck)
if retval = 0 then
retval = oSession.AsObject(oSession.UI).MessageBox("Error reading UDF_Phantom_Kit from SO_UDT_Phantom_Kits" & vbcrlf & oUDT.LastErrorMsg)
end if

'retVal = oSession.AsObject(oSession.UI).MessageBox("Phantom Kit: " & sPhantom & vbcrlf & "Phantom Check: " & sPhantomCheck)


retval = oUDT.MoveNext()

oScript.LinesAdded = -1


Loop

Parents
  • First, make sure your button script is set to run on the Server, not workstation.

    set oUDT = oSession.AsObject(oUDT)

    do until oUDT.EoF

  • in reply to Kevin M

    Thanks, Kevin.  I just tried that variation, see below, per your suggestion.  I also removed the SetBrowseFilter, in case.  I'm getting the same error: Error 20 Syntax Error.  Program: SY_Commonui.pvc.  Any other thoughts?

    Revised Code Below

    -----------------------------------------------------------------------

    oUDT = oSession.GetObject("CM_UDTMaint_bus", "SO_UDT_Phantom_Kits")

    if oUDT = 0 then 'run if user has permission to access UDT (oUDT would be zero if insufficient permissions)
    retVal = oScript.SetError("Unable to read SO_UDT_Phantom_Kits table. The user may not have permissions to this table and other UDTs. This entry will not be saved.")

    else 'continue if user has permissions

    Set oUDT = oSession.AsObject(oUDT)

    'retVal = oUDT.SetBrowseFilter(sPhantom)

    retval = oUDT.MoveFirst() 'start looping through ALL UDT records to search for this phantom item

    do until oUDT.EoF

    retval = oUDT.GetValue("UDF_Phantom_Kit$", sPhantomCheck)
    if retval = 0 then
    retval = oSession.AsObject(oSession.UI).MessageBox("Error reading UDF_Phantom_Kit from SO_UDT_Phantom_Kits" & vbcrlf & oUDT.LastErrorMsg)
    end if


    'retVal = oSession.AsObject(oSession.UI).MessageBox("Phantom Kit: " & sPhantom & vbcrlf & "Phantom Check: " & sPhantomCheck)


    retval = oUDT.MoveNext()

    Loop

    'retVal = oLines.EditLine(sLineKey)

    '**************search UDT for component items to add to this order ************************************************


    end if 'run if user has permission to access UDT

  • in reply to n0tgunshy2

    You checked your button script is running from the Server, not Workstation?

    This is critical.

  • in reply to Kevin M

    Oh, and SetError means nothing in a button script.  That only works in Pre-... events for BOI triggers.  Change that to message box.

    retVal = oSession.AsObject(oSession.UI).MessageBox(sMsg)

  • in reply to Kevin M

    Thanks, Kevin.  It is running on the Server.  And I'm not using a seterror.  Got any other ideas?

  • in reply to Kevin M

    Ooops.  I had that commented that out on my side, not sure how I uncommented it when I posted here. 

    I'm still getting the error and it's happening here: Do until oUDT.EOF

    Any other ideas? And thanks!

Reply Children