I have a table which contains “hours worked” for different trades (electrical, plumbing…) there are 14 of them. A single record has a field for each trade. There is also a field for total hours, which is the total of all trade’s hours for that record. I know this could be calculated at runtime – but the user wants it as a field to simplify reporting
I am struggling with how to keep the total hours calculated in the table. On the form I have an “After Update” event which looks like below for each of the trades. txttotaltime is the lable of the textbox that writes data to the total hours field, totaltime.
Private Sub txtpltotal_AfterUpdate()
txttotaltime.Value = [txteltotal] + [txtpltotal]
End Sub
I’m using that exact same code for each of the 14 trade’s afterupdate time entries.
The questions are: is there a way to create a function that could to do the addition, then just call that function in the AfterUpdate event on the form?
And – the calculation only works if there is a value in every one of the trades hours fields. I have the table set up to give a 0 default value, but if the user deletes the 0, it will not add. I suppose the function would need to check for null or value less than 1, and assign it a 0 if that is true.
Any help would be appreciated, even if someone has a completely different idea of how to do this.
I am struggling with how to keep the total hours calculated in the table. On the form I have an “After Update” event which looks like below for each of the trades. txttotaltime is the lable of the textbox that writes data to the total hours field, totaltime.
Private Sub txtpltotal_AfterUpdate()
txttotaltime.Value = [txteltotal] + [txtpltotal]
End Sub
I’m using that exact same code for each of the 14 trade’s afterupdate time entries.
The questions are: is there a way to create a function that could to do the addition, then just call that function in the AfterUpdate event on the form?
And – the calculation only works if there is a value in every one of the trades hours fields. I have the table set up to give a 0 default value, but if the user deletes the 0, it will not add. I suppose the function would need to check for null or value less than 1, and assign it a 0 if that is true.
Any help would be appreciated, even if someone has a completely different idea of how to do this.