Solved

Comments in Microsoft Access 2013 query

Posted on 2014-10-13
5
5,852 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
Comment Utility
Comments are prefixed by a single quote (I often use two).
Dashes are for SQL Server.


Kelvin
0
 
LVL 18

Author Comment

by:daveslash
Comment Utility
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
Comment Utility
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:LukeChung-FMS
LukeChung-FMS earned 250 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

11 Experts available now in Live!

Get 1:1 Help Now