Kemidan2014
Board Regular
- Joined
- Apr 4, 2022
- Messages
- 229
- Office Version
- 365
- Platform
- Windows
I am helping a co worker from another department with their database as the original creator no longer works for Company. They asked me if it was possible for a total feild to automatically add up values from other fields and still be bound to the table while doing so.
My solution was to use VBA in the form on _Afterupdate to add values from the fields so that it displays the number in the Total field (which is tied to the same table as the other field values I am adding up
The VBA adds up the values but gives me a Macro error 2950 and gives me options to stop all macros. is this a Code problem or a Client settings problem? I googled the error and it all suggests Trust center settings but i have enabled them and i still get the error.
I am working on a back up copy of the original front end. below is the code I added to perform the math.
The original problem they had is they needed the Totals for each record event with in a certain time frame. what I found out was happening is no one was entering in the totals in the Total_b field because they were instructed not to as their supervisor who worked on this database used an expression in a REPORT that was NOT tied to the table to add up values. but the problem with it is after the 3rd record it just repeated the same value over and over regardless of what the true math would be for each record.
I found a solution for this by editing the query where the report is generating from by having the QUERY do the math NOT the report fields. This corrected the export BUT. it still did not update the table with the summed up values so i have thousands of records with 0 in the Total_b field
my approach:
1) fix the data entry to enter values into the table for the total while overcoming user errors in doing math themselves and either a) entering in incorrect values or b) skipping this step because they're in a rush
2) Run a simple update query to do a one-time math function to put in the correct values in the total_b field in the table.
My solution was to use VBA in the form on _Afterupdate to add values from the fields so that it displays the number in the Total field (which is tied to the same table as the other field values I am adding up
The VBA adds up the values but gives me a Macro error 2950 and gives me options to stop all macros. is this a Code problem or a Client settings problem? I googled the error and it all suggests Trust center settings but i have enabled them and i still get the error.
I am working on a back up copy of the original front end. below is the code I added to perform the math.
VBA Code:
Private Sub Form_AfterUpdate()
Me.Total_b.Value = Me.RI_b.Value + Me.DC_MO_b.Value + Me.FI_b.Value + Me.MA_b.Value + Me.AS_b.Value + Me.WPAS_b.Value + Me.WPMA_b.Value + Me.QC_b.Value + Me.HT_GC_b.Value + Me.RM_b.Value + Me.ST_b.Value + Me.Ship_b.Value + Me.Dock_b.Value
End Sub
The original problem they had is they needed the Totals for each record event with in a certain time frame. what I found out was happening is no one was entering in the totals in the Total_b field because they were instructed not to as their supervisor who worked on this database used an expression in a REPORT that was NOT tied to the table to add up values. but the problem with it is after the 3rd record it just repeated the same value over and over regardless of what the true math would be for each record.
I found a solution for this by editing the query where the report is generating from by having the QUERY do the math NOT the report fields. This corrected the export BUT. it still did not update the table with the summed up values so i have thousands of records with 0 in the Total_b field
my approach:
1) fix the data entry to enter values into the table for the total while overcoming user errors in doing math themselves and either a) entering in incorrect values or b) skipping this step because they're in a rush
2) Run a simple update query to do a one-time math function to put in the correct values in the total_b field in the table.