Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to retain proper spacing in Access SQL strings

Status
Not open for further replies.

Clipper2000

Programmer
Nov 28, 2004
54
US
Hi,

I code a lot of Access queries manually, and sometimes the string can get pretty long, such as:

Code:
TRANSFORM Sum([tbl90707].[Amount]) AS Amount
SELECT [NelNetRollUp].[Total], [NelNetRollUp].[SubTotal], [tblNelNetMapEdulinx].[Account], [tblNelNetMapEdulinx].[subAcct], [tbl90707].[Accpac], [tbl90707].[Description], [tblNelNetRollUpOrder].[RollUpOrder]
FROM ((tbl90707 LEFT JOIN tblNelNetMapEdulinx ON clng([tbl90707].[Accpac])=[tblNelNetMapEdulinx].[Accpac]) LEFT JOIN NelNetRollUp ON [tblNelNetMapEdulinx].[Account] & [tblNelNetMapEdulinx].[subAcct]=[NelNetRollUp].[Acct] & [NelNetRollUp].[Sub Acct]) LEFT JOIN tblNelNetRollUpOrder ON [NelNetRollup].[Total]=[tblNelNetRollUpOrder].[Total]
WHERE ([tbl90707].[Category]="EDU" And [tbl90707].[Period]=9 And [tbl90707].[Year]=2004 And clng([tbl90707].[Accpac])>39999 Or [tbl90707].[Category]="EDU" And [tbl90707].[Period]=8 And [tbl90707].[Year]=2004 And clng([tbl90707].[Accpac])>39999 Or [tbl90707].[Category]="EDU" And [tbl90707].[Period]=7 And [tbl90707].[Year]=2004 And clng([tbl90707].[Accpac])>39999)
GROUP BY [NelNetRollUp].[Total], [NelNetRollUp].[SubTotal], [tblNelNetMapEdulinx].[Account], [tblNelNetMapEdulinx].[subAcct], [tbl90707].[Accpac], [tbl90707].[Description], [tbl90707].[Category], [tblNelNetRollUpOrder].[RollUpOrder]
ORDER BY [tblNelNetRollUpOrder].[RollUpOrder], [tblNelNetMapEdulinx].[Account], [tblNelNetMapEdulinx].[subAcct]
PIVOT (cstr([Period] & [Year]))

I would like to retain the proper format spacing such as:

Code:
TRANSFORM Sum([tbl90707].[Amount]) AS Amount

SELECT 

[NelNetRollUp].[Total], [NelNetRollUp].[SubTotal], [tblNelNetMapEdulinx].[Account], [tblNelNetMapEdulinx].[subAcct], [tbl90707].[Accpac], [tbl90707].[Description], [tblNelNetRollUpOrder].[RollUpOrder]

FROM tbl90707

LEFT JOIN
tblNelNetMapEdulinx ON clng([tbl90707].[Accpac])=[tblNelNetMapEdulinx].[Accpac])
LEFT JOIN NelNetRollUp ON [tblNelNetMapEdulinx].[Account] & [tblNelNetMapEdulinx].[subAcct]=[NelNetRollUp].[Acct] & [NelNetRollUp].[Sub Acct]) 
LEFT JOIN tblNelNetRollUpOrder ON [NelNetRollup].[Total]=[tblNelNetRollUpOrder].[Total]

WHERE ([tbl90707].[Category]="EDU" And [tbl90707].[Period]=9 And [tbl90707].[Year]=2004 And clng([tbl90707].[Accpac])>39999 Or [tbl90707].[Category]="EDU" And [tbl90707].[Period]=8 And [tbl90707].[Year]=2004 And clng([tbl90707].[Accpac])>39999 Or [tbl90707].[Category]="EDU" And [tbl90707].[Period]=7 And [tbl90707].[Year]=2004 And clng([tbl90707].[Accpac])>39999))

GROUP BY [NelNetRollUp].[Total], [NelNetRollUp].[SubTotal], [tblNelNetMapEdulinx].[Account], [tblNelNetMapEdulinx].[subAcct], [tbl90707].[Accpac], [tbl90707].[Description], [tbl90707].[Category], [tblNelNetRollUpOrder].[RollUpOrder]

ORDER BY [tblNelNetRollUpOrder].[RollUpOrder], [tblNelNetMapEdulinx].[Account], [tblNelNetMapEdulinx].[subAcct]
PIVOT (cstr([Period] & [Year]))

It seems that every time when I saved the query with the proper spacing etc, the next time I open up the SQL definition, all the spaces are gone.

Is there a way to over come this?

Your help would be greatly appreciated.
 
Never go back to query grid...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top