Hmm, I didn't chime in because you said
(the code is in a qry not vba sql)
but now say
I converted the qry to sql
Access queries are based on a sql syntax (albeit specific to Access). I think you meant you had formed a sql statement and were trying to execute it using vba? Code sql statements are not processed by the same part of Access so you cannot use things like Forms!frmMain... without concatenation. That is, such object references cannot be part of the literal string that comprises actual sql.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.