setting a db object's HIDDEN property in code

K

Keith G Hicks

Anyone have any ideas how to set the HIDDEN property of db objects (all of
them - tables, queries, forms, reports, macros, modules) using CODE. So far
I have the following for forms but it doesn't actually change the property.
It runs fine, just doesn't do anything:

Dim db As Database
Set db = CurrentDb

Dim ctr As Container
Dim frm As Form
Dim doc As Document
Dim prp As Property

Dim bFoundProp As Boolean
bFoundProp = False

' Return referenct to Forms container.
Set ctr = db.Containers!Forms
' Enumerate through Documents collection of Forms container.
For Each doc In ctr.Documents
bFoundProp = False
Debug.Print doc.Name
doc.Properties.Refresh

For Each prp In doc.Properties
If prp.Name = "Hidden" Then
bFoundProp = True
Exit For
End If
Next prp

If bFoundProp = False Then
Set prp = doc.CreateProperty("Hidden", dbBoolean, False)
doc.Properties.Append prp
Debug.Print doc.Name, doc.Properties("Hidden")
End If

doc.Properties("Hidden") = False

Next doc


I'm sure I have to work "Attributes" in there somewhere, but the ms access
help on this topic sucks.

Thanks,

Keith
 
D

Dirk Goldgar

Keith G Hicks said:
Anyone have any ideas how to set the HIDDEN property of db objects
(all of them - tables, queries, forms, reports, macros, modules)
using CODE. So far I have the following for forms but it doesn't
actually change the property. It runs fine, just doesn't do anything:

Dim db As Database
Set db = CurrentDb

Dim ctr As Container
Dim frm As Form
Dim doc As Document
Dim prp As Property

Dim bFoundProp As Boolean
bFoundProp = False

' Return referenct to Forms container.
Set ctr = db.Containers!Forms
' Enumerate through Documents collection of Forms container.
For Each doc In ctr.Documents
bFoundProp = False
Debug.Print doc.Name
doc.Properties.Refresh

For Each prp In doc.Properties
If prp.Name = "Hidden" Then
bFoundProp = True
Exit For
End If
Next prp

If bFoundProp = False Then
Set prp = doc.CreateProperty("Hidden", dbBoolean, False)
doc.Properties.Append prp
Debug.Print doc.Name, doc.Properties("Hidden")
End If

doc.Properties("Hidden") = False

Next doc


I'm sure I have to work "Attributes" in there somewhere, but the ms
access help on this topic sucks.

For A2K or later, look up the Application.SetHiddenAttribute method in
the online help. Here's an example:

Application.SetHiddenAttribute acForm, "frmMyForm", True
 
K

Keith G Hicks

thanks :)

Dirk Goldgar said:
For A2K or later, look up the Application.SetHiddenAttribute method in
the online help. Here's an example:

Application.SetHiddenAttribute acForm, "frmMyForm", True

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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