How can I prevent the code I write in Access SQL from being automatically reformatted into multiple lines?

Mine Dayan 0 Reputation points
2026-07-08T09:52:06.6633333+00:00

Even if I write my SQL code on a single line in Access, it gets automatically reformatted into multiple lines when I run the query. How can I prevent this?

Microsoft 365 and Office | Access | Development

1 answer

Sort by: Oldest
  1. Michelle-N 20,735 Reputation points Microsoft External Staff Moderator
    2026-07-08T10:55:44.62+00:00

    Hi @Mine Dayan

    Based on your description, I understand that you are writing SQL code inside Microsoft Access, and even if you write a query on a single line, Access automatically reformats it into multiple lines with tabs and line breaks whenever you save or execute it. You want to know how to stop this automatic reformatting behavior and preserve your original layout.

    This behavior is actually part of a major upgrade Microsoft introduced to the Access SQL Editor starting around version 2506. Microsoft integrated the modern Monaco Editor (the engine behind VS Code) into Access. While this brought highly requested features like syntax highlighting and IntelliSense, it also introduced automatic SQL pretty-formatting, which forces queries into a multi-line, structured layout by default.

    Here is how you can manage or disable this feature to keep your SQL on a single line:

    -If you are running a recent version of Access (such as Build 2604), Microsoft introduced a dedicated query-level property to bypass automatic pretty-printing while letting you keep the new editor's benefits.

    Open your target query in Design View or SQL View > Open the Property Sheet > Look for the property named No Format > Check or toggle No Format to True / Selected > Save your query.

    From now on, Access will preserve your exact whitespace layout for this specific query.

    VBA Tip: You can also toggle this property programmatically for any saved query using VBA:

    CurrentDb.QueryDefs("YourQueryName").Properties("NoFormat") = True

    Even with No Format turned on, you can still trigger a one-time manual format adjustment inside the SQL view whenever you want by pressing Ctrl + K.

    -If you want to globally turn off automatic formatting across your current application, you can opt out of the Monaco Editor entirely.

    Go to File > Options > Select Current Database from the left-hand menu > Scroll down and locate the option: Enable Monaco SQL Editor > Uncheck this box > Click OK, then close and reopen your Access database.

    This drops Access back to its old legacy SQL view textbox. It will stop all automatic formatting, but please keep in mind that you will also lose all modern editor features, including:

    • Syntax coloring (everything reverts to plain black text)
    • Autocomplete / IntelliSense dropdowns
    • Error underlining and advanced keyboard shortcuts

    -For complex development work, the cleanest solution is to stop relying on saved QueryDefs for complex SQL:

    • Write the SQL directly in VBA as a string variable and execute it with CurrentDb.Execute or assign it to a form/report's RecordSource.
    • Your formatting (including single-line or custom line breaks using _ line continuation) stays exactly as you wrote it.
    • This gives you full control and is much more maintainable for complex queries.

    I hope these modern setting changes help you regain control over your SQL layout.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click ""Comment"".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.