Solved

update mainform from subform calculation

Posted on 2003-12-01
14
531 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access Runtime 2010 Error 17 33
SQL profiler equivalent in MS-Access 3 45
MS Access Order Smallest to Biggest Query Help 13 43
word 2016 1 0
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

863 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

24 Experts available now in Live!

Get 1:1 Help Now