How do you comment an MS-access Query?

前端 未结 9 1873
失恋的感觉
失恋的感觉 2020-12-29 20:04

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?

相关标签:
9条回答
  • 2020-12-29 20:54

    You can add a comment to an MSAccess query as follows: Create a dummy field in the query. Not elegant but is self-documentating and contained in the query, which makes cheking it into source code control alot more feasible! Jere's an example. Go into SQL view and add the dummy field (you can do from design view too):

    SELECT  "2011-01-21;JTR;Added FIELD02;;2011-01-20;JTR;Added qryHISTORY;;" as qryHISTORY,  ...rest of query here...
    

    Run the query:

    qryHISTORY                           FIELD01 FIELD02 ...
    2011-01-21;JTR;Added FIELD02;;2011-01-20;JTR;Added qryHISTORY;;"  0000001  ABCDEF ...
    

    Note the use of ";" as field delimiter in qryHISTORY field, and ";;" as an end of comment, and use of ISO date format and intials, as well as comment. Have tested this with up to 646 characters in the qryHISTORY field.

    0 讨论(0)
  • 2020-12-29 20:56

    The first answer mentioned how to get the description property programatically. If you're going to bother with program anyway, since the comments in the query are so kludgy, instead of trying to put the comments in the query, maybe it's better to put them in a program and use the program to make all your queries

    Dim dbs As DAO.Database
    Dim qry As DAO.QueryDef
    
    Set dbs = CurrentDb
    'put your comments wherever in your program makes the most sense
    dbs.QueryDefs("qryName").SQL = "SELECT whatever.fields FROM whatever_table;"
    DoCmd.OpenQuery "qryname"
    
    0 讨论(0)
  • 2020-12-29 21:03

    In the query design:

    • add a column
    • enter your comment (in quotes) in the field
    • uncheck Show
    • sort in assending.

    Note:

    If you don't sort, the field will be removed by access. So, make sure you've unchecked show and sorted the column.

    0 讨论(0)
提交回复
热议问题