Compare amounts form and subform

  • Thread starter Thread starter DBarker
  • Start date Start date
D

DBarker

I have a main form that contains a subform. In the main
form they place the total of an invoice. In the subform
they put the detail say the invoice gets split between
different accounts. Before they move to a new record I
want to compare the totals that they entered and make
sure that it equals the amount they put in the header as
the total invoice. Any ideas, I know this has to be
relatively easy but I am stumped.

Thanks,
Debbie
 
Hi Debbie,

You would think that this would be an easy thing to do,
but I'm not so sure. Comparing the totals would be
fairly easy. You could add a text box to the footer of
the subform and give it the value =
sum([YourSubformField]). Then, that control value could
be checked against the control value on the main form.

The part where it gets tricky is when you look at where
to put the validation code that would compare the two
values. Access does not include an event for RecordExit
(at least through A2002, which is what I have) even
though it is in the help file.

There are a number of postings on this issue in the past,
which you can locate by going to
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-
8&group=microsoft.public.access and searching
for "recordexit". There are some links to a workaround
in VB, but it will require doing some ADO programming.

If you really need to enforce the validation, you may
want to consider getting rid of the built-in navigation
buttons and replacing them with your own navigation
buttons. That way, the validation code could be run
through the buttons' click events.

Another option that you could consider if you just want
to notify the user as to whether the values add up, but
not really enforce the validation, would be to have a
text box with an iif() statement as the control source
which displays a different message depending on whether
the totals match.

This is kind of general info. It's hard to give much
more detail without knowing which route you would want to
choose. Post back if you would like more info on a
particular direction.

-Ted
 
Back
Top