Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you comment an MS-access Query?

How does one add a comment to an MS Access Query, to provide a description of what it does?

Once added, how can one retrieve such comments programmatically?

like image 772
Varun Mahajan Avatar asked Oct 31 '08 13:10

Varun Mahajan


People also ask

Can you add notes in access query?

Hi, No, it is not possible. You can use the query Description property just for a comment.


4 Answers

I decided to add a condition to the Where Clause that always evaluates true but allows the coder to find your comment.

Select
   ...
From
   ...
Where
   ....
   And "Comment: FYI, Access doesn't support normal comments!"<>""

The last line always evaluates to true so it doesn't affect the data returned but allows you to leave a comment for the next guy.

like image 121
Dan Avatar answered Sep 25 '22 01:09

Dan


It is not possible to add comments to 'normal' Access queries, that is, a QueryDef in an mdb, which is why a number of people recommend storing the sql for queries in a table.

like image 35
Fionnuala Avatar answered Sep 24 '22 01:09

Fionnuala


NOTE: Confirmed with Access 2003, don't know about earlier versions.

For a query in an MDB you can right-click in the query designer (anywhere in the empty space where the tables are), select Properties from the context menu, and enter text in the Description property.

You're limited to 256 characters, but it's better than nothing.

You can get at the description programatically with something like this:

Dim db As Database
Dim qry As QueryDef

Set db = Application.CurrentDb
Set qry = db.QueryDefs("myQuery")

Debug.Print qry.Properties("Description")
like image 11
Patrick Cuff Avatar answered Sep 23 '22 01:09

Patrick Cuff


I know this question is very old, but I would like to add a few points, strangely omitted:

  1. you can right-click the query in the container, and click properties, and fill that with your description. The text you input that way is also accessible in design view, in the Descrption property
  2. Each field can be documented as well. Just make sure the properties window is open, then click the query field you want to document, and fill the Description (just above the too little known Format property)

It's a bit sad that no product (I know of) documents these query fields descriptions and expressions.

like image 4
iDevlop Avatar answered Sep 25 '22 01:09

iDevlop