Recalculate Main Form Data

bbrendan

Registered User.
Local time
Today, 00:43
Joined
Oct 31, 2001
Messages
35
Hi All,

I need a little help with trying to re-query a mainform box

Heres the deal.

I have an order entry form which is made up of 2 forms, Main form and Sub form. The main Form has all the customer information, and order total fields.
An example of thie is [Order Total]

The subform contains the Line Details

The problem is that when-ever I enter a new line onto the subform the main form [order total] does not update.

The [order total] box has the following code.

=([SubTotal]+[ShippingCost]+[TotalTax])

These fields are summary fields I have placed in the footer of the sub form to calculate out the line totals.

The strange thing is that when I put put the cursor into the main form [Order total] Box I can see the updated value.

Its as if im not refeshing the [order total] box!.

I have tried putting
after update on the sub form
forms!frm_main.[order total].requery - this doesnt fix it!
also tried

forms!frm_main.[order total].refresh - Doesnt work Errors out

Anyone got any sugesstions as to why this is behaing like this???

thanks
 
The main form cannot update until after the subform updates. That's why when you move the cursor out of the subform and into the maingorm it updates. That action causes the subform record that you just added/changed to be saved. The same result would be achieved if you moved from one subform record to another.

You can force the current record to be updated with the following -

DoCmd.RunCommand acCmdSaveRecord

This will work in any event EXCEPT the form's Before and After update events.
 
Hi Pat,

thanks for your help. You pointed me in the right direction.

Ive just put some code behind the after update events

forms!frm_main.refresh

This refreshes the whole form, like the docmd does.



cheers
 

Users who are viewing this thread

Back
Top Bottom