Hello All,
I have this code below that is working however the calculation are updating on my form late.
Basically, I have some calculation that are performed on a "After Update" event on some controls on my form. I wanted it to do the calculation after I update the control on the form.
The code is in a module and I just call the function after update on the control But the form is not updating when I change the value in a field. I have to change the field again for it to update.
What am I missing? Any ideas?
Control
Function
Thanks
I have this code below that is working however the calculation are updating on my form late.
Basically, I have some calculation that are performed on a "After Update" event on some controls on my form. I wanted it to do the calculation after I update the control on the form.
The code is in a module and I just call the function after update on the control But the form is not updating when I change the value in a field. I have to change the field again for it to update.
What am I missing? Any ideas?
Control
Code:
Call GeraAuditCalc
DoCmd.RefreshRecord
Function
Code:
Function GeraAuditCalc()
Dim fHrs As Double
Dim Ttl As Double
Dim Ttl1 As Double
Dim Ttl2 As Double
Dim Ttl3 As Double
Dim Ttl4 As Double
Dim Ttl5 As Double
Dim Ttl6 As Double
Dim Ttl7 As Double
Dim AuditID As Long
AuditID = Forms![Gera Audit]![ID]
fHrs = Forms![Gera Audit]![Mon-Hrs]
Forms![Gera Audit]![Tue-Hrs] = fHrs
Forms![Gera Audit]![Wed-Hrs] = fHrs
Forms![Gera Audit]![Thu-Hrs] = fHrs
Forms![Gera Audit]![Fri-Hrs] = fHrs
Forms![Gera Audit]![GMon-Hrs] = fHrs
Forms![Gera Audit]![GTue-Hrs] = fHrs
Forms![Gera Audit]![GWed-Hrs] = fHrs
Forms![Gera Audit]![GThu-Hrs] = fHrs
Forms![Gera Audit]![GFri-Hrs] = fHrs
Forms![Gera Audit]![Sat-Hrs] = fHrs
Forms![Gera Audit]![Sun-Hrs] = fHrs
Forms![Gera Audit]![GSat-Hrs] = fHrs
Forms![Gera Audit]![GSun-Hrs] = fHrs
Forms![Gera Audit]![GNew Sensors] = 0
Forms![Gera Audit]![GFix Hrs Adj Wk] = 0
' Totals Correct
Ttl = DSum("[% Ballast] * [Fixtures] * [Ball Mat] + [Ball Labor]", "tblMainGera", "[ID] = Forms![Gera Audit]![ID]")
Forms![Gera Audit]![Ttl Ballast M$] = Ttl
' Totals Correct
Ttl1 = DSum("[Input-Watts] * [Fix Hrs Wk] * 52 / 1000", "tblMainGera", "[ID] = Forms![Gera Audit]![ID]")
Forms![Gera Audit]![kWh Burn Yr] = Ttl1
' Totals Correct
Ttl3 = DSum("[Lamp $] + [Labor $] + [Equipment $]", "tblMainGera", "[ID] = Forms![Gera Audit]![ID]")
Forms![Gera Audit]![Ttl Lamp M$] = Ttl3 * Forms![Gera Audit]!Lamps
Ttl4 = DSum("[Mon-Hrs] + [Tue-Hrs] + [Wed-Hrs] + [Thu-Hrs] + [Fri-Hrs] + [Sat-Hrs] + [Sun-Hrs]", "tblMainGera", "[ID] = Forms![Gera Audit]![ID]")
Ttl5 = DSum("[GMon-Hrs] + [GTue-Hrs] + [GWed-Hrs] + [GThu-Hrs] + [GFri-Hrs] + [GSat-Hrs] + [GSun-Hrs]", "tblMainGera", "[ID] = Forms![Gera Audit]![ID]")
Forms![Gera Audit]![Wrk Hrs Wk] = Ttl4
Forms![Gera Audit]![GWrk Hrs Wk] = Ttl5
Ttl6 = DSum("[Fixtures] * [Wrk_Hrs_Wk]", "tblMainGera", "[ID] = Forms![Gera Audit]![ID]")
Forms![Gera Audit]![Fix Hrs Wk] = Ttl6
Forms![Gera Audit]![GAdj Fix Hrs Wk] = Forms![Gera Audit]![GWrk Hrs Wk] - Forms![Gera Audit]![GFix Hrs Adj Wk]
Ttl7 = DSum("[GInput-Watts] * [GFixtures] * [GAdj_Fix_Hrs_Wk] * 52 / 1000", "tblMainGera", "[ID] = Forms![Gera Audit]![ID]")
Forms![Gera Audit]![GkWh Burn Yr] = Ttl7
Forms![Gera Audit]![GkWh Saved yr] = Forms![Gera Audit]![kWh Burn Yr] - Ttl7
Forms![Gera Audit]![GPercentage of Energy Saved] = Forms![Gera Audit]![GkWh Saved yr] / Forms![Gera Audit]![kWh Burn Yr
End Function
Thanks