Community

Проверка по строке таблицы Цена* Количество = Сумма


Использованию данного скрипта должна предшествовать нормализация всех сумм.

Dim newCost, newPrice, newQty

Dim ComparResult


newCost = me.Field("Sum").Text
newPrice = me.Field("Price").Text
newQty = me.Field("Qty").Text

Dim separator
separator = Mid( CStr(1.1),2,1)

if separator = "." then
newCost = Replace( newCost, ",", separator)
newPrice = Replace( newPrice, ",", separator )
newQty = Replace( newQty, ",", separator )
else
newCost = Replace( newCost, ".", separator)
newPrice = Replace( newPrice, ".", separator )
newQty = Replace( newQty, ".", separator )
end if

if ((newCost <> "") and not IsNumeric (newCost)) then
Exit Sub
end if

if ((newPrice <> "") and not IsNumeric (newPrice)) then
Exit Sub
end if

if ((newQty <> "") and not IsNumeric (newQty)) then
Exit Sub
End if

if (newCost <> "") and (newPrice <> "") and (newQty <> "") Then
ComparResult = Abs( newPrice * newQty - newCost)
if ComparResult > 0.01 Then
me.ErrorMessage = "(Кол-во * цена) отличается от суммы. Разница: " & CStr(Round(ComparResult,2))
me.CheckSucceeded = False
me.Field("Sum").Suggest(CStr (Abs( newPrice*newQty - 0)))
End if
elseif (newCost = "") and (newPrice <> "") and (newQty <> "") Then
newCost = Abs( newPrice * newQty - 0)
newCost = CStr(Round(newCost,2))
me.Field("Sum").Text = newCost

End if
0

Comments

0 comments

Please sign in to leave a comment.