?
Solved

Comments in Microsoft Access 2013 query

Posted on 2014-10-13
5
Medium Priority
?
8,997 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 earned 1000 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 1000 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

771 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