Hola Che...
If you're in a hurry, I suggest you add a dummy record so that the function works adecuately.
Otherwise, you might want to check whether you're at eof() or how many records are there in the view/cursor/table you're working on and then modify the code's behavior based on that.
Good luck!
Alex
Low-carb diet not working? Try the Low-food diet instead!