Please can you post your whole program and put it in code tags (# above the smileys)The problem may not actually be in your function at all but without seeing all of your code it is impossible to help.

Please do not send me PMs asking for help. Post in the forum then everyone will benefit from seeing the questions and answers.