Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want calculations to update immediately

Status
Not open for further replies.

debbieg

Technical User
Dec 2, 2002
190
US
I have a main form with a tab control with 2 pages. Each page has a subform (both continuous forms) on it. Both subforms have totals on them for Regular Hours and Overtime Hours. I have 2 textboxes for Grand Totals in the footer of the main form. As I go from record to record in the main form, the Grand Totals update fine.

My problem is if I change a value in a record on either subform, I want the Grand Totals in the main form footer to update immediately.

I have tried everything that I know to get this to work (Recalc, Requery, Refresh, etc.) but it’s not working. I must not be putting something in the right place. I even tried putting the Grand Totals in the footer of the subform on the 1st page of the tab control but couldn’t get that to work either.

I've been working on this for hours and I give up until I hopefully hear something from this forum.

Thanks,
Debbie
 
How are ya debbieg . . . .

In the [blue]AfterUpdate event[/blue] of those controls on the subForms involved in the totals, copy/paste the following:
Code:
[blue]Forms![purple][b]MainFormName[/b][/purple].ReCalc[/blue]

Calvin.gif
See Ya! . . . . . .
 
TheAceMan1,

I'm not doing well! [nosmiley]

I did what you suggested and still no automatic update of the Grand Totals. I even changed it to Me.Parent.Recalc but that didn't work either.

I also put this on the subforms' AfterUpdate but still doesn't work.

Any other ideas? This is nuts!

Debbie
 
Yes!

Pick one subform and a respective control you'd change on that subform. Then:
[ol][li]If the associated total on the subform doesn't change when you change data add [purple]Me.Recalc[/purple] to the [blue]AfterUpdate[/blue] of the control (total on subform should now update)[/li]
[li]After the above, if the associated total on the [purple]mainform[/purple] doesn't change as well, follow [purple]Me.ReCalc[/purple] with [purple]Forms!MainFormName.ReCalc[/purple] (dont forget to substitute the proper name for MainFormName) . . .[/li][/ol]
That should do it. Finish the other involved controls . . .

Calvin.gif
See Ya! . . . . . .
 
TheAceMan1,

I appreciate you taking the time to help me.

The totals on the subforms DO update after updating the record.

It's the Grand Totals on the main form that aren't updating.

This is the code I put in the total fields in one subform:
Code:
Private Sub TotOTHrs_AfterUpdate()
    Forms!frmHoursWorked.Recalc
End Sub

Private Sub TotRegHrs_AfterUpdate()
    Forms!frmHoursWorked.Recalc
End Sub

I tried putting Me.Recalc in there also but that didn't help. Is this what you're talking about? I put the same in the other subform also.

Am I not understanding you correctly?

Thanks,
Debbie

 
I finally got it!
Code:
Me.Parent.Recalc
Me.Parent!GrandTotalReg = Nz(Me.Parent!subfrmHoursWorked.Form!txtSumRegHrs, 0) _
        + Nz(Me.TotRegHrs, 0)
Me.Parent!GrandTotalOT = Nz(Me.Parent!subfrmHoursWorked.Form!TotOTHrs, 0) _
        + Nz(Me.TotOTHrs, 0)
I'm going to bed for some needed sleep! [dazed]

Thanks,
Debbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top