str (lower case) is weird in this regard. Sometimes it is allowed in msaccess vba and sometimes it throws a strange error that seems context-oriented. Don't use it. mystr, for example works fine).
BTW, this especially a bugaboo using the Immediate Pane since Option Explicit not enforced in the Immediate Pane (Access 2016 desktop).