Updating a calculating text box.

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Updating a calculating text box.

Post by Egg 'n' Bacon »

I have this text box that calculates from another text box (on the parent form) with another on a sub-form (data is entered here last). This will only show the result when the parent form is closed and re-opened.

What is the best method to get this to calculate whilst the form is open?

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Updating a calculating text box.

Post by HansV »

Is the text box on the subform bound to a field in the record source of the subform, or is it a calculated control too?
And what is the Control Source of the calculated text box on the main form?
Best wishes,
Hans

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Updating a calculating text box.

Post by Egg 'n' Bacon »

OK... answering in order;
the text box on the sub-form is not bound to a field. It too is a calculated control (gives max of related records).
The control source for the calculated text box on the main form is yet another calculation... well a conversion really;
=IIf([VolVal]="High",3,IIf([VolVal]="med",2,1))

Does that make sense?

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Updating a calculating text box.

Post by HansV »

You could create an After Update event procedure for the subform:

Code: Select all

Private Sub Form_AfterUpdate()
    Me.Parent.Recalc
End Sub
If necessary, you can also recalculate the main form in the On Current event of the main form itself:

Code: Select all

Private Sub Form_Current()
    Me.Recalc
End Sub
Best wishes,
Hans

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Updating a calculating text box.

Post by Egg 'n' Bacon »

Cheers Hans, the first one does the trick.

Thank you