Skip to main content

If statement to apply a field equation

I wrote a function that iterates through a database and returns true if a string is found and false if it is not found.
 I inserted the string into code as indicated below to apply an eqn to a field.
 
If StringExists("PayElements-SpecialPay","ELEMENT",rec.GetCharValue("ELEMENT_NAME")) field.Equation = "XXXXXX"Elsefield.Equation = "YYYYYY"End If
When it ran it did not itterate throug the fields it ean only once. I added a loop to iterate through the code.  Lets say I have a 100 record database.  It read the first record and looped 100 times. Then read the 2nd and looped 100 times.  My DB was much larger and I had to kill the process.  
My question is how do I itterate through a database to apply a field equation.  I was doing it in the equation editor but there are a lot of items in the list and it made a very ugly equation.  A table is a much simpler and effecient way of doing it.
 
Thanks,
Randy