Set Query Description in VB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a function that deletes my query and recreates it. Everytime it does
this it kills my description that I put in for the query. How can I program
in the description. I have tried using

qd.CreateProperty.properties ("This is my description")

but it keeps telling me invalid use of 'properties'
 
James said:
I have a function that deletes my query and recreates it. Everytime
it does this it kills my description that I put in for the query.

Don't delete and recreate.
Simply change the SQL-Property, so your description
remains.

Acki
 
The reason that I am deleting the SQL query over and over again, is because
it gets replaced with different queries each time. It depends on report the
user clicks on. The SQL Query is just a temp storage.

I want the description so that if anyone goes into the db, they can easily
know what is in the SQL without having to break it down.
 
James said:
The reason that I am deleting the SQL query over and over again, is
because it gets replaced with different queries each time. It depends
on report the user clicks on. The SQL Query is just a temp storage.

I want the description so that if anyone goes into the db, they can
easily know what is in the SQL without having to break it down.

----------------------------------------------------------
Option Explicit

Sub SetQueryDescription(strQueryName As String, strDescription As String)

On Error GoTo Error_SetQueryDescription

Dim db As DAO.Database
Dim qdf As DAO.querydef
Dim prp As DAO.Property

Set db = CurrentDb
Set qdf = db.querydefs(strQueryName)
qdf.Properties!Description = strDescription

Exit_SetQueryDescription:
Set prp = Nothing
Exit Sub
Error_SetQueryDescription:
If Err = 3270 Then
Set prp = qdf.CreateProperty("Description", dbText, strDescription)
qdf.Properties.Append prp
Resume Next
Else
MsgBox Str(Err.Number) & " " & Err.Description
Resume Exit_SetQueryDescription
End If
End Sub
 
Back
Top