J
Joe Williams
I have a main form with a subform embedded that lists percentages for each
main form record. The total of all the percentages in the subform records
for each main record MUST equal 100%.
I have put a footer in the subform that totals the percentage fields. No
problem. Now where I am struggling is in where to check and trap the error
if the total of all the percentages is < or > 100%.
I have tried several subform events (On Change, AfterUpdate) to check the
total of the percentages field and make sure it is 100%. It works most of
the time but there seems to be different ways the user can make a mistake
and not be caught by the different events I am checking it on. (For
instance, I can change percentage values in the subform and then click back
to the main form without either the On Change or AfterUpdate event firing to
check the total from the subform.) So the possiblity exists that you could
move on to antoher main form record with the subform record percentages
being incorrect.
My thought process was maybe I should just do the check before I leave each
main record rather than trying to check everytime a user enters values in
the subform. Would this be the most efficient way to do this?
If so, what main form event can I use to check the percentage totals from
the subform that would prevent the user from moving off of the current
record unless the subform values are correct? How would I go about coding
it?
Thanks
Joe
main form record. The total of all the percentages in the subform records
for each main record MUST equal 100%.
I have put a footer in the subform that totals the percentage fields. No
problem. Now where I am struggling is in where to check and trap the error
if the total of all the percentages is < or > 100%.
I have tried several subform events (On Change, AfterUpdate) to check the
total of the percentages field and make sure it is 100%. It works most of
the time but there seems to be different ways the user can make a mistake
and not be caught by the different events I am checking it on. (For
instance, I can change percentage values in the subform and then click back
to the main form without either the On Change or AfterUpdate event firing to
check the total from the subform.) So the possiblity exists that you could
move on to antoher main form record with the subform record percentages
being incorrect.
My thought process was maybe I should just do the check before I leave each
main record rather than trying to check everytime a user enters values in
the subform. Would this be the most efficient way to do this?
If so, what main form event can I use to check the percentage totals from
the subform that would prevent the user from moving off of the current
record unless the subform values are correct? How would I go about coding
it?
Thanks
Joe