Adding a property to a query object

S

SuperScooper

I'm setting up a form that will allow me to quickly apply/update
properties to forms, queries, reports, etc in an access 2000 database.

Using the following, I can quickly add and update a user defined
property on my forms:

Dim obj As AccessObject

For Each obj In CurrentProject.AllForms

obj.Properties.Add ("RevDate"), Date$
obj.Properties.Add ("RevTime"), Time$
obj.Properties.Add ("Version"), "v1.0"

Next obj

The problem I'm having though involves attempting similar code with
queries. ie, the following code generates a 2467 error "The
expression you entered refers to an object that is closed or doesn't
exist"

Dim obj As AccessObject
Dim dbs As Object
Set dbs = Application.CurrentData

For Each obj In dbs.AllQueries

obj.Properties.Add ("RevDate"), Date$
obj.Properties.Add ("RevTime"), Time$
obj.Properties.Add ("Version"), "v1.0"

Next obj

Anyone know if it is possible to append a user defined property to the
query object?

Thanks in advance.
 
M

Michel Walsh

Hi,



CurrentDb.QueryDefs("Query32").Properties.Append
CurrentDb.CreateProperty("Hello", dbText, "Hello")



to create the property. You can list the properties like:

=======================
Public Sub ListAllProp()
Dim prop As DAO.Property
Dim qdf As QueryDef

Set qdf = CurrentDb.QueryDefs("Query32")
For Each prop In qdf.Properties
Debug.Print prop.Name
Next prop

End Sub
==========================




Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top