This topic is locked
[SOLVED]

 BeforeAdd Calculation

4/1/2010 8:59:25 AM
ASPRunnerPro General questions
M
mark.field author

Hi,
It's been a long week and my brain is way past mush! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=14181&image=1&table=forumtopics' class='bbc_emoticon' alt=':blink:' />
I'm trying to add some validation using the BeforeAdd function to add two values together and compare to a third, and produce an error message if it doesn't work.
I've got some working where it is comparing two vales e.g.
if dict("RecordType") = "Excess on Receipt" and dict("QtyAdvised") >= dict("QtyReceived") Then

BeforeAdd = False

message="<div class=message><<< " & "Qty Advised must be less than Qty Received >>></div>"

end if
In this example, I want to validate a third value dict("Quantity") and error if QtyAdvised-QtyReceived <> Quantity.
This is sure to be simple but see sentence one!
Any help gratefully received

J
Jane 4/2/2010

Hi,
try to use this one:

if dict("RecordType") = "Excess on Receipt" and dict("QtyAdvised") >= dict("QtyReceived") and dict("QtyAdvised")-dict("QtyReceived)<>dict("Quantity") Then

message="<div class=message><<< " & "Qty Advised must be less than Qty Received >>></div>"

BeforeAdd = False

end if
M
mark.field author 4/6/2010



Hi,
try to use this one:

if dict("RecordType") = "Excess on Receipt" and dict("QtyAdvised") >= dict("QtyReceived") and dict("QtyAdvised")-dict("QtyReceived)<>dict("Quantity") Then

message="<div class=message><<< " & "Qty Advised must be less than Qty Received >>></div>"

BeforeAdd = False

end if



Thanks Jane but it didn't work, but have found something that does...

if dict("RecordType") = "Excess on Receipt" and CInt(dict("QtyAdvised")) >= CInt(dict("QtyReceived")) and CInt(dict("QtyAdvised"))-CInt(dict("QtyReceived))<>CInt(dict("Quantity")) Then

message="<div class=message><<< " & "Qty Advised must be less than Qty Received >>></div>"

BeforeAdd = False

end if


<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=49007&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />