• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 579
  • Last Modified:

update mainform from subform calculation

I have a main form which pulls a Sum'd calculation NetAmt from the footer of the subform; however ... the NetAmt on the mainform seems to update before the NetAmt on the subform ... so the mainform is always one step behind.

Literally, when I leave the subform, I see the mainform's NetAmt update ... and then 1/2 second later the NetAmt on the subform update ... making the mainform one step behind.
0
tljprincess
Asked:
tljprincess
  • 7
  • 6
1 Solution
 
jobrienctCommented:
Hi tj,

perhaps in your subforms control, in the after update event, add Me.Parent.Refresh

see if that helps

John
0
 
tljprincessAuthor Commented:
nope, that didn't work ... the subform is continuous forms and when i did that, it made the previous record disappear on the subform (although it was saving those individual records ... the NetAmt didn't ever show any value)
0
 
jobrienctCommented:
can you send your database? check my profile for the email address if you can.

John
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tljprincessAuthor Commented:
i really can't ... confidentiality .. however, i can give you more details

the main form is a treatment form (for a Dr.) ... the subform lists all the specific treatment types, cost, qty .... then the subtotal of the subform's Costs (Net Amt) is pulled to the mainform and called the BalanceDue.  I do this with a Sum field in the footer of the subform and then I pull that field to the mainform with the formula =[TRdetail subform].Form!TRsubformSubtotal

i have created a test button that does the docmd.repaintobject on the mainform and if i hit that button twice, it finally is right ... however, even if i put in the docmd.repaintobject twice on the one button (instead of hitting it twice) ... that doesn't work either.  
0
 
jobrienctCommented:
interesting problem. can you possibly copy the database, empty the copy of confidential information and enter just enough bogus data to show me the problem and send that?

Im sure I could figure it out if I was looking at it. If you can't then tell me what event of what control on the subform you use to update the main form. Or am i reading right that you are updating the main forms Balance due from the main form?

If thats the case I think you may need to reverse the process. in the subforms control where you store the sum, in its after update event try Me.Parent.txtBalandue.value = mySumControlname.value (is that TRsubformSubtotal?)

John
0
 
jadedataMS Access Systems CreatorCommented:
Hey tljprincess!

  One way to slay a beast like this is to write a function that is called by the appropriate AfterUpdate or Current (or other) events to keep the calculated fields sync'd on the form.

  The subform can call such a function with a name like Form_RecalculateAll() on the main form:
   me.parent.Form_RecalculateAll

  This function could FORCE the recalc/refresh/repaint of all of the controls on the form at once, IN THE ORDER you specify.

regards
Jack
0
 
jobrienctCommented:
jade if her control is in the footer of a subform, .Parent still refers to the main form right?

John
0
 
tljprincessAuthor Commented:
John, wonderful ... simple answer.  Thank you!
0
 
tljprincessAuthor Commented:
WAIT! John ... hold on ... I tested it with multiple records in the subform and it didn't work ... ahhh!  It is as if I need to save that last record in the subform ... so the AfterUpdate isn't running on that last record because it isn't saved.  
0
 
tljprincessAuthor Commented:
ok ... it is too late ... retract that last statement and revert back to the previous

John ... great job and thank you.
0
 
jobrienctCommented:
huh wha who? retract what, revert to what? im lost, is it working? :)

John
0
 
tljprincessAuthor Commented:
all is working ... sorry for the confusion ... how do you suggest i do the point?
0
 
jobrienctCommented:
tj,

You need to assign points according to the help you received. for instance in this question you have myself and jadedata assisting you, if one of us helped you and the other did not then you can simply choose the helpful answer and assign the points there. if both answers were helpful you should split the points, accepting the most helpful answer and assigning points to the assisting answer approriately. Its really completely up to you, but you need to do it thoughtfully. Its monopoly money, but it's your monopoly money :)

In this case you have already assigned the points to my question by accepting it, I can however remedy it by splitting those points with JD myself, otherwise to make a change would require administrative intervention, and they're busy guys :)

JD I'll post points in the main forum for you referencing this question.

regards,

John
0
 
tljprincessAuthor Commented:
i think it is appropriate the way I did it ... thanks so much!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now