Update form or controls

oxicottin

Learning by pecking away....
Local time
Today, 04:35
Joined
Jun 26, 2007
Messages
891
Hello, I have a test form with a text box named txtMinutes where I enter minutes into and tab then it subtracts those minutes from txtAccTimeWorked and changes minutes to hours and enters the answer into txtDTRegular. Also if there is time in txtDTReason1,txtDTReason2 and txtDTMaintenance it subtracts from the txtAccTimeWorked. Everything works the way I want it but, If I go back to a record I have already calculated the "Delay" and maybe added some time to txtDTMaintenance it doesnt recalculate the delay. I have to go and re-enter the minutes in the "Run Minutes" and tab for it to recalculate the delay. How do I make it recalculate the delay if I change the time in any control? Thanks!
 

Attachments

Refresh

Hi,

In your afterupdate event code where you're doing the calculations, add a line me.refresh

If I understand your problem correctly that should sort it.

HTH

Mary
 
Mary, My question is if I calculated the number already and then I decided to change the DT Reason 1, Then it doesnt update the delay. If I add the refresh to that text box then it doesnt do anything for me if I change the time somewhere else on the form. Any sugestions?

Thanks!
 
Refresh

Then put the me.refresh in the afterupdate event of the control you are changing.

Am I reading you properly this time? It IS Monday :-)

M
 
Ok, Im going to try to explain this better. If I enter 1.00 into the txtDTReason1 "DT Reason 1' text box and then enter 400 into the txtMinutes "Enter Run Minutes" text box then it will give me an answer in the txtDTRegular "Delay" text box of 0.33. Now if I decide to change the 1.00 I entered into the txtDTReason1 "DT Reason 1' text box to 0.50 and click somewhere it doesnt change my "Delay" to the correct answer of 0.83. It will change it if I go to the "Enter Run Minutes" text box and re-enter the 400 minutes and tab then it will show the correct delay hours. Hope this helps....
 
AfterUpdate

Ok, think I finally have you now. You need to put same after update event in the DT box as in the run box, ie Me.txtDTRegular = Round((txtAccTimeWorked) - (txtMinutes / 60), 2)

Please tell me I understood you correctly this time! :-)


M.
 
Hi Mary I am also answering this question as he has double posted which, being polite, really annoys me.

Brian
 
Not really a double post Brian Just another question to the same DB I was working on...:p Sorry I didnt realize it was consided that. My apogees! Mary my origional post is here! Thanks for the help...
 
Last edited:
You have your form set up to calculate "Delay" (txtDTRegular) when the AfterUpdate event of "Enter Run Minutes" (txtMinutes ) fires, using the formula

Me.txtDTRegular = Round((txtAccTimeWorked) - (txtMinutes / 60), 2)

As set up, that's the only condition under which this calculation is done! So changing one of the elements, such as txtDTReason1, is not going to cause this calculation to be redone. In point of fact, if you were to enter "Run Minutes" first, then enter "DT Reason1" the calculation wouldn't be done the first time. You need to add the calculation to the AfterUpdate event of each controls where you could poddibly change the values, like this:

Code:
Private Sub txtDTMaintenance_AfterUpdate()
Me.txtDTRegular = Round((txtAccTimeWorked) - (txtMinutes / 60), 2)
End Sub

Private Sub txtDTReason1_AfterUpdate()
Me.txtDTRegular = Round((txtAccTimeWorked) - (txtMinutes / 60), 2)
End Sub

Private Sub txtDTReason2_AfterUpdate()
Me.txtDTRegular = Round((txtAccTimeWorked) - (txtMinutes / 60), 2)
End Sub

BTW, the link you gave is for this thread, not your original thread!
 
Last edited:
Thank you all, this works great!

Sorry for all the confusion! And the link is fixed...
 

Users who are viewing this thread

Back
Top Bottom