lets have this example

record 1
qty:1

record 2
qty:1

total of all record is 2
total to be compared is 4

lets say he/she wants to edit record 2,user then input the desired number in a textbox(txtquantity.text)

how should i limit the user so that the quantity he can enter txtquantity.text is from 3 to 1 only

because total to be compared is only 4

update should then look like this

record 1
qty:1

record 2
qty:3 ( if user entered 3 ) but if user enters 4 in txtquantity.text it will flag an error

total of all record is 4
total to be compared 4

hope i made it clear