Although the last post in this thread was 2013, I just ran into this issue TODAY in April 2021 using 10.5.1. Received the error until I turned on the layer in the TOC. Crazy that it wouldn't work without the layer being physically visible (I was just using the Attribute Tables).
Same here!! And I'm using 10.7.1
And in 10.8.1