Link to home
Create AccountLog in
Avatar of morinia
moriniaFlag for United States of America

asked on

SQL query formatting loss in Access VBA

Experts,

Not a big issue, but is there any way to keep the formatting in an SQL Query in Access?
I find it easier to read and modify when the query is not all together on one line.
example:
Select
        TableA.FieldA,
        TableA.FieldB,
        TableA.FieldC,
        TableB.FieldD
From TableA join TableB
on TableA.FieldA = TableB.FieldA;

When I close and reopen query  get  something like this.

Select TableA.Fielda,TableA.Fieldb, ableA.Fieldc,TableB.FieldD,From TableA  join TableB on TableA.FieldA = TableB.FieldA;
EXPERT CERTIFIED SOLUTION
Avatar of Daniel Pineault
Daniel Pineault

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
removed VBA topic
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of Daniel Pineault
Daniel Pineault

@Ste5an

I tried and it did not work for me.  What version is required for this to work?  Is this some new feature only available in MS 365?
No, it's the way it worked all the years back. Not sure what version it was introduced. But it worked for sure since 2010.

btw, with query I mean a query in the query pane, not a SQL statement in the property editor.
Thanks for the clarification.  I'm running 2013 and besides line feeds, everything else is loss when I try it.
I'm currently working most the time with 2013 and 2016 and it works in both for me. Do you use an tools, which touches your queries?
No, nothing, just base Office Install with updates.  Don't worry about it.  I don't want to hijack this thread. I can always start a thread of my own.
E.g.

INSERT INTO dbo.SY03900 ( NOTEINDX, DATE1, TIME1, TXTFIELD )
VALUES  ( 10148391.00000, CAST(GETDATE() AS DATE), CAST(GETDATE() AS TIME), '');

Open in new window