Thanks very much. I would say that I do not agree with you on not saving. It
is fine if you understand how undo works in Access, but I have generally
found that it does somethng I do not want, so I have adopted a rule that undo
is fine in Word, but in Access it is much safer to manually correct any
typos. However the main reason is that saving on data entry means that when
the last shareholder is entered, if the aggregate total is incorrect, the
user is immediately alerted to check that he has made an error in entering
share numbers - which is why I want to make Aggregate Total a calculated
field.
The record with the edited ShareNumber field has to be saved
before Access can recalculate the value. If you force the
record with the new value to be saved, then you take away
the ability for users to hit the Esc key to undo any/all
edits to the record.
I think that's a very good reason for things to work the way
they do and why I think you should not try to "make it
update when the user exits the ShareNumber field".
If you insist on doing what you ask, the code in the
ShareNumber field's text box's AfterUpdate event would be:
Me.Dirty = False
Dudley wrote:
Thanks very much for your help. That works, although the total only updates
when you move to another record. Is it possible to make it update when the
user exits the ShareNumber field in the sub sub form?
:
Dudley wrote:
I have a sub-form which is linked to the main form on control EnvelopeNumber
, and a sub-sub-form which is linked to the sub-form on control ShareClass. I
want control AggregateNumber in the sub-form to be the total of numbers
entered in the ShareNumber control in the sub-sub-form. I assume that I
should enter code in On Exit in the ShareNumber control, so that the total is
updated whenever the user adds or amends a record, but the code is beyond my
knowledge.
I don't think using code is the way to go. The standard way
to do that is to put a (hidden?) text box (named txtTotal)
in the subsubform's header or footer section with an
expression like =Sum([ShareNumber field]) to calculate the
total. Note that [ShareNumber field] must be the name of
the record source field, not the name of a control.
With that in place, your AggregateNumber text box on the
subform can use an expression like:
=[subsubform control name].Form.txtTotal