I want to build a function that sets chosen fields to 0.
I want to simplify my function since i have to repeat and and the same line
code.
I am doing now the following
Public function ClearFields()
' set the field Field2 to 0
Dim sqlField2 as string
sqlField2 = " Update products SET Field2 = 0"
CurrentDb.Execute SqlField2
' set the field Field4 to 0
Dim sqlField5 as string
sqlField5 = " Update products SET Field5 = 0"
CurrentDb.Execute SqlField5
etc etc I have 5 more fields to set to 0"
Is there any way to simplify my code, put the fields into brackets and just
contain the function into one or two lines ?
I want to simplify my function since i have to repeat and and the same line
code.
I am doing now the following
Public function ClearFields()
' set the field Field2 to 0
Dim sqlField2 as string
sqlField2 = " Update products SET Field2 = 0"
CurrentDb.Execute SqlField2
' set the field Field4 to 0
Dim sqlField5 as string
sqlField5 = " Update products SET Field5 = 0"
CurrentDb.Execute SqlField5
etc etc I have 5 more fields to set to 0"
Is there any way to simplify my code, put the fields into brackets and just
contain the function into one or two lines ?