To extract the SQL from a QueryDef (saved Access query) it is only necessary to view the query in SQL View. This shows the underlying SQL for the QueryDef and is in simple text form (See Access QueryDefs Mis-save Subquery SQL for problems that may occur with SubQueries in your SQL). When a QueryDef is open (either in Design View or Datasheet View) it is possible to switch to the SQL View simply by selecting View \ SQL View from the menu.
From here it is simple to Copy & Paste it to wherever you need it. Please remember it is always better to post Copy/Pasted work here at Bytes to avoid any inadvertent mistakes that can waste much time.
It is also possible to paste (or simply type) SQL into a QueryDef in this way. Be careful though. Once the SQL has been updated this way Access will disallow viewing the QueryDef in Design View unless the SQL is found to be valid and of a displayable type (UNION queries are the most common of non-displayable types). Sub-queries (Subqueries in SQL) can be handled in Design View. The sub-query is simply displayed as any other record source.
It is wise to switch back to Design View to check the SQL is valid (and test it where possible) before saving away your updated QueryDef. A QueryDef saved while in SQL View will open again in that view.