Solved

update mainform from subform calculation

Posted on 2003-12-01
14
518 Views
Last Modified: 2010-08-05
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
Comment
Question by:tljprincess
  • 7
  • 6
14 Comments
 
LVL 10

Expert Comment

by:jobrienct
ID: 9855943
Hi tj,

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

see if that helps

John
0
 

Author Comment

by:tljprincess
ID: 9855989
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
 
LVL 10

Expert Comment

by:jobrienct
ID: 9856034
can you send your database? check my profile for the email address if you can.

John
0
 

Author Comment

by:tljprincess
ID: 9856094
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
 
LVL 10

Accepted Solution

by:
jobrienct earned 250 total points
ID: 9856146
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
 
LVL 32

Expert Comment

by:jadedata
ID: 9856176
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
 
LVL 10

Expert Comment

by:jobrienct
ID: 9856198
jade if her control is in the footer of a subform, .Parent still refers to the main form right?

John
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:tljprincess
ID: 9856223
John, wonderful ... simple answer.  Thank you!
0
 

Author Comment

by:tljprincess
ID: 9856237
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
 

Author Comment

by:tljprincess
ID: 9856289
ok ... it is too late ... retract that last statement and revert back to the previous

John ... great job and thank you.
0
 
LVL 10

Expert Comment

by:jobrienct
ID: 9856350
huh wha who? retract what, revert to what? im lost, is it working? :)

John
0
 

Author Comment

by:tljprincess
ID: 9915782
all is working ... sorry for the confusion ... how do you suggest i do the point?
0
 
LVL 10

Expert Comment

by:jobrienct
ID: 9915960
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
 

Author Comment

by:tljprincess
ID: 9916878
i think it is appropriate the way I did it ... thanks so much!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now