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
Solved

Comments in Microsoft Access 2013 query

Posted on 2014-10-13
5
7,262 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

809 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