I have a form that on the "AfterUpdate" it calls an Event Procedure that does three things.
1. Runs a Macro that does a "Set Value" to another field on the form
2. Executes a SQL statement that performs a Sum on the field that just got updated in the macro.
3. Executes a SQL statement that performs an Update to another table with the sum that was computed.
My problem is that the value the Macro is setting is not being included in the Sum/Update statements. Here is my code for reference.
Private Sub UpdateTotal
DoCmd.RunMacro "Update Total"
' this sets the value of bau_total on the form
intTotal = DSum("bau_total", "BallotUsage", "bau_loc = '" & Me![bau_loc] & "' and bau_type = '" & Me![bau_type] & "' and bau_pre = '" & Me![bau_pre] & "'")
If intTotal > 0 Then
CurrentDb.Execute "Update [Ballot Percent Alerts] set bpa_total = " & intTotal & " where bpa_loc = '" & Me![bau_loc] & "' and bpa_type = '" & Me![bau_type] & "' and bpa_pre = '" & Me![bau_pre] & "'"
End If
End Sub
How can I get the macro to commit the value to the database so that it will be included in the Dsum OR is there another way to accomplish this.
1. Runs a Macro that does a "Set Value" to another field on the form
2. Executes a SQL statement that performs a Sum on the field that just got updated in the macro.
3. Executes a SQL statement that performs an Update to another table with the sum that was computed.
My problem is that the value the Macro is setting is not being included in the Sum/Update statements. Here is my code for reference.
Private Sub UpdateTotal
DoCmd.RunMacro "Update Total"
' this sets the value of bau_total on the form
intTotal = DSum("bau_total", "BallotUsage", "bau_loc = '" & Me![bau_loc] & "' and bau_type = '" & Me![bau_type] & "' and bau_pre = '" & Me![bau_pre] & "'")
If intTotal > 0 Then
CurrentDb.Execute "Update [Ballot Percent Alerts] set bpa_total = " & intTotal & " where bpa_loc = '" & Me![bau_loc] & "' and bpa_type = '" & Me![bau_type] & "' and bpa_pre = '" & Me![bau_pre] & "'"
End If
End Sub
How can I get the macro to commit the value to the database so that it will be included in the Dsum OR is there another way to accomplish this.
