Solved

Comments in Microsoft Access 2013 query

Posted on 2014-10-13
5
8,394 Views
Last Modified: 2014-10-15
Greetings, esteemed experts!

In MicroSoft Access 2013, when creating a query in SQL view, how do you add a comment? I tried the standard "two-dashes" method and the /* stuff */ method, but Access doesn't like either. Is it possible?

Thanks in advance!
DaveSlash
0
Comment
Question by:Dave Ford
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40378757
Comments are prefixed by a single quote (I often use two).
Dashes are for SQL Server.


Kelvin
0
 
LVL 18

Author Comment

by:Dave Ford
ID: 40378778
Thanks for your quick response, Kelvin. I tried the single-quote, but it throws an error no matter where I put it.

Try putting a comment at the top:

'some comment
INSERT INTO SOMETABLE
SELECT *
FROM SomeOtherTable;

"Invalid SQL Statement; expected 'DELETE', 'INSERT', 'PROCEDURE', or 'UPDATE'"

Open in new window


Try putting a comment in the middle:

INSERT INTO SOMETABLE
'some comment
SELECT *
FROM SomeOtherTable;

"Syntax error in INSERT INTO statement"

Open in new window


Try putting a comment at the bottom, after the semi-colon:

INSERT INTO SOMETABLE
SELECT *
FROM SomeOtherTable;
'some comment

"Characters found after end of SQL Statement"

Open in new window


Try putting a comment at the bottom, before the semi-colon:

INSERT INTO SOMETABLE
SELECT *
FROM SomeOtherTable 'some comment
;

"Invalid bracketing of name '' some comment

Open in new window


What am I missing?
0
 
LVL 48

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 total points
ID: 40378861
As you have found, there is no way to actually embed your comments in the SQL of the query in Access.  

Rather than using the query properties as mentioned by Kelvin, I generally create a table where I store the name and a description of all of my database objects (well, at least the tables, forms, queries, and reports).  This allows me to create a query of the objects in the mSysObjects table joined to tbl_db_Objects, to identify orphaned or undefined data base objects.  It also helps me to create documentation for each application.
0
 
LVL 10

Assisted Solution

by:Luke Chung
Luke Chung earned 250 total points
ID: 40379672
Queries have a description property that can be used for comments. You can't do it in the SQL window itself.

An alternative would be to create the query in VBA and add all the comments you want there. Of course you wouldn't see that if you opened the query directly.

In general, most Access developers and users never use the SQL pane and use the Design pane instead.
0
 
LVL 18

Author Closing Comment

by:Dave Ford
ID: 40382526
Thank you!

I don't like the answer (that there's essentially no good way to put comments in an Access SQL query), but I've been married long enough to know that there are many things in life I'll never understand. I just have to deal gracefully with the "limitations" I've been dealt. :-)

Thanks again!
DaveSlash
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question