empty calculated control on subform

  • Thread starter Thread starter Bob L.
  • Start date Start date
B

Bob L.

I have a subform with a calculated control in the footer that uses
sum([myfieldname]). On the main form I have a command button I use to move
to the next record. When clicked it calls a function to check the value of
the calculated text box to be sure it totals 1.0 before advancing to the
next record.

My problem is that when I open the form with data, the calculated text box
shows 100% as it should for that data. When I click the button however, the
value of the textbox is apparently empty instead of 1.0 as it should be
(confirmed this with watch variable and debug). If I click it again,
however it works fine. I can then go back and forth between records and the
check function works just fine. That is, the problem is only for the first
record after opening the form. If I watch the calculated text box I can
actually see it goes to empty as soon as I click the cmd button on the main
form.

I have tried requerying the subform, setting the focus to a text box in the
subform, etc but nothing seems to work. Any help would be greatly
appreciated.

TIA
Bob
 
I found a workaround so thought I would post it for those who come after me.
Not clear why it works, but I included code before the code checking the
total that sets the focus to the subform where the calculated total is
located and then sets the focus to the textbox in the detail section that is
the argument in my sum(), i.e. the field that is totaled.

Now it works, though not clear to me why this is necessary. Is this a bug
or something I should have known?

Bob
 
Back
Top