I have a Access table with fields named MM1, MM2, MM3...MM17.
I need to add 1 to the current value stored in the field, depending on the result of some calculations done on several variables.
The code I currently use, was proposed by ChatGPT, but it does not work. Code as follows:
Code:
Case 9
Me!Frm_TyreForecastSubForm.Form!("MM0_" & Me("MM" & t) - Val(MinMM)) = Me!Frm_TyreForecastSubForm.Form!("MM0_" & Me("MM" & t) - Val(MinMM)) + 1
If t = 1 Then FieldName = "MM" & t
CurrentDb.Execute "UPDATE TempMMtable SET " & FieldName & " = " & FieldName & " + 1 WHERE CLRegistration = '" & rs!CLRegistration & "';"
In the above scenario, the result is not important, but the field "MM1" must be changed by 1. The SQL statement should read as follows (just for clarity sake):
"UPDATE TempMMtable SET MM1 = MM1 +1;" - Because t was equal to 1, field MM1 needs to be updated. If t = 2, then field MM2 must be updated with 1.
Any suggestions?
Thanks