Solved

Comments in Microsoft Access 2013 query

Posted on 2014-10-13
5
6,417 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:daveslash
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:daveslash
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 47

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:daveslash
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now