views:

5445

answers:

3

What is syntax for adding comments in an access query?

+1  A: 

See Add a comment to an Access Query

Galwegian
that works for adp's (2K3), what about mdb's (<=2k)?
CodeSlave
+1  A: 

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.

Remou
That's not true. See the accepted answer.
Mathieu Pagé
Is that a comment in the usual sense? To me, it is a custom property, not a comment.
Remou
+2  A: 

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")
Patrick Cuff