I noticed that when SQL statement does not return a record then null string causes the Err # 3091. First we have to handle this error and then suggest accordingly.lik e ....

function()
on error goto xErr
sql statement......
.............
.......
xErr:
if err.number=3091 then
resume next
your code when sql statement...... fails to return.
end if
end function...