Cascading Form Update

espua

Registered User.
Local time
Tomorrow, 05:20
Joined
Sep 15, 2005
Messages
11
Hi all,

I encounter a problem here.

I have a main form (OrderForm) with a subform (OrderDetails). In the OrderDetails subform, I put a [txtSubSumOrder] TextBox at the subform footer to perform the Sum of the OrderDetails. To pass the [txtSubSumOrder] data back to the main OrderForm, I put another TextBox [txtMainSumOrder]=[OrderDetails].[txtSubSumOrder] at the main OrderForm. Therefore, I can calculate the commission for sales, profit and etc for the Order in the main OrderForm by using the data from the[txtMainSumOrder].

The challenge is I need to wait untill the [txtMainSumOrder] has been sucessfully updated with the changes in the OrderDetails subform before I can perform the calculation accurately. But programmatically, how do I know/detect the [txtMainSumOrder] has been successfully updated, before I initiate the calculation routine? I try the [Enter], [After Update] and various events for the [txtMainSumOrder] control, but I still fail to detect the changes has been take place.

Help ............
 
As you have discovered, the priority for getting those controls updated is somewhat lower than other elements within Access. I personally use a different technique. Rather than set the ControlSource of a control on the MainForm to point to a control on the SubForm, I update the MainForm control from the SubForm with code. I have a SubRoutine in the SubForm called UpdateParent and in there I do whatever need doing including running through the underlying RecordSetClone summing things. I call this SubRoutine in the Current event of the SubForm and in the AfterUpdate event of any control that might change the totals.

I also have a Public SubRoutine in the MainForm called Syncronize that I call after I've updated the Parent controls:

Me.Parent.txtTotal1 = MyCollectedTotal1
Me.Parent.txtTotal2 = MyCollectedTotal2
Call Me.Parent.Syncronize
 
As you have discovered, the priority for getting those controls updated is somewhat lower than other elements within Access. I personally use a different technique. Rather than set the ControlSource of a control on the MainForm to point to a control on the SubForm, I update the MainForm control from the SubForm with code. I have a SubRoutine in the SubForm called UpdateParent and in there I do whatever needs doing including running through the underlying RecordSetClone summing things. I call this SubRoutine in the Current event of the SubForm and in the AfterUpdate event of any control that might change the totals.

I also have a Public SubRoutine in the MainForm called Syncronize that I call after I've updated the Parent controls:

Me.Parent.txtTotal1 = MyCollectedTotal1
Me.Parent.txtTotal2 = MyCollectedTotal2
Call Me.Parent.Syncronize

I am now in charge of the timing and not Access.
 
Hi RG,

Thanks so much for your advice, that's exactly the problem I'm facing. By the way, how does the Synchronize routine in the Parent Form looks like? How do it force the Parent text box to reflect the changes that made by the subform?
 
I'm not sure I understand your question but
Me.Parent.txtTotal1 = MyCollectedTotal1 '<-- This updates a Parent TextBox
Me.Parent.txtTotal2 = MyCollectedTotal2 '<-- and so does this line
Call Me.Parent.Syncronize

What ever code you were going to use on the MainForm to do your calculations is in the Syncronize SubRoutine.
 
hi RG,

Thanks !! I have got the problem solved !!
 
Great news! Thanks for posting back with your success.
 

Users who are viewing this thread

Back
Top Bottom