As you say there may be a problem with the variable. I suggest that you outline what is in that variable, and how it is created, perhaps with some sample values. If it's a field name, then does it need to be enclosed with delimiters (eg the field name contains spaces)?
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein