Solved

update mainform from subform calculation

Posted on 2003-12-01
14
556 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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
 

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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Email question 19 87
access vba 5 53
Combo box question 6 49
Could someone write me an SQL query for MS Access? 4 28
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

737 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