How do I force MS Access to retain its SQL formatting?

If you have admin access to your PC (required for installation), Access SQL editor could be the right tool.
I never used it: as a consultant I rarely have the right to install stuff on the machines I use, but it looks exactly like what I would like to have: a replica of the SSMS editor.


Sometimes the method proposed by @Pureferret can fail with Access keeping reformatting the SQL.

The only way I've found that works all the time is to append a UNION ALL block at the end of the query.
Indeed as Access does not handle UNION ALLs it won't even propose to edit in design mode.
(I've tried with UNION but got an Overflow error!)

SELECT
    ...
    ...
FROM
    ...
WHERE
    ...
UNION ALL SELECT NULL, NULL, NULL FROM ANY_TABLE WHERE NULL

(if targetting a real table bothers you, you can use a "Dual" table to the database)

Moreover I find it a little "cleaner" to only add one line at the end.
But you need to write as many NULLs as there are selected fields in the real query.

EDIT: /!\ Be careful with this method in sub-queries as it can cause some Query too complex error in queries using it! :(


I found a hack, here. The secret lies in enclosing your query inside a dummy query. Like so:

SELECT * FROM (SELECT   <-----here
Table1.Field1,
Table1.Field2
FROM
Table1

WHERE
Table1.Field2 = "Yes") AS query1 <-----here

I've indicated where and how you wrap the code. The only issue I can see is if you wanted to edit the code in design view, then it doesn't seem to pick the enclosed code up at all.