User Defined Script causing an error

I created the following script to populate ShipWeight$ in the CI_Item table when either of 2 UDF's are changed.

I am now receiving an error 88 type mismatch (error window below).  Any thoughts?

START OF CODE

Dim retVal
Dim cpwgt
Dim cpwgtstr
Dim itemwgt
Dim itemwgtstr
Dim casepack

retVal = ""
cpwgt = 0
cpwgtstr = ""
itemwgt = 0
itemwgtstr = ""
casepack = 0


' Retrieve the Case Pack value data elements
retVal = oBusObj.GetValue("UDF_CASEPACK_WGT$", cpwgtstr)
retVal = oBusObj.GetValue("UDF_CASEPACK", casepack)

' protect against casepack being zero
if casepack = 0 then casepack = 1

' Convert from a string to a nunber
cpwgt = Val(cpwgtstr)


' Calc CI Item Weight
itemwgt = Round((cpwgt / casepack), 4)

' Convert to string and format to display all 4 decimal places
itemwgtstr = FormatNumber(itemwgt, 4)

' Update the CI Item Weight data element
retVal = oBusObj.SetValue("ShipWeight$", itemwgtstr)

END OF CODE

Top Replies