calculated control event order

M

Michelle K.

I have a continuous subform with a calculated control in the footer to total
a field on the subform. I'm trying to use events/code to "copy" that total
to a bound control in the main form. Can't just use a calculated control on
the main form (=subform!total) because the "total" on the main form may be
over-ridden by a value at users discretion.

I've tried using the AfterUpdate event (as well as others) of the subform
control that can change (and therefore change the value of the total), but it
appears that the calculated controls are not being updated until sometime
after the GotFocus event of the next control on the subform. So after my
code for the event has run and the focus is on the next control on the
subform, the calculated total on the subform is correct, but the bound
control on the main form shows the total before the update, not after. I am
saving the current record as the first step in the event code, then using
forms![main form]![bound field]=me.totalfield to update the main form bound
field.

Any help is greatly appreciated!
 
J

Jeanette Cunningham

You can use this code to force access to update a calculated control
On the subform the code would be
Me.Recalc

Then you could call the code that puts that total in the main form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
M

Michelle K.

Thank you!! That was exactly what I needed.

Jeanette Cunningham said:
You can use this code to force access to update a calculated control
On the subform the code would be
Me.Recalc

Then you could call the code that puts that total in the main form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Michelle K. said:
I have a continuous subform with a calculated control in the footer to
total
a field on the subform. I'm trying to use events/code to "copy" that
total
to a bound control in the main form. Can't just use a calculated control
on
the main form (=subform!total) because the "total" on the main form may be
over-ridden by a value at users discretion.

I've tried using the AfterUpdate event (as well as others) of the subform
control that can change (and therefore change the value of the total), but
it
appears that the calculated controls are not being updated until sometime
after the GotFocus event of the next control on the subform. So after my
code for the event has run and the focus is on the next control on the
subform, the calculated total on the subform is correct, but the bound
control on the main form shows the total before the update, not after. I
am
saving the current record as the first step in the event code, then using
forms![main form]![bound field]=me.totalfield to update the main form
bound
field.

Any help is greatly appreciated!


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top