un-hiding tables

G

Guest

Hello,
I was wondering if there is a way to un-hide tables using code.
I know it can be done via DAO, but I would know it this may be accomplished
via ADOX.

I have wrote this code to discover which property should I use:

Dim cat As New ADOX.Catalog
Set cat.ActiveConnection = CurrentProject.Connection
With cat
For Each Table In .Tables
If Table.Type = "table" Then
For Each Property In Table.Properties
MsgBox Property.Name & "---> " & Property.Value
Next
End If
Next
End With

I found a property named:
"Jet OLEDB: Table Hidden In Access", its value was setted=true. I figured
this was what I needed, but...
If I code something like:
table.properties("Jet OLEDB: Table Hidden In Access").value=true
it wont work.

Why?

thanks
rocco
 
G

Guest

Hi, Rocco.
If I code something like:
table.properties("Jet OLEDB: Table Hidden In Access").value=true
it wont work.

Why?

It may be working, but you can't see it because when you look at the table
in the Database Window, the Hidden attribute doesn't appear to have been
changed. However, if one switches to another tab, say the Queries tab, then
switches back again to the Table tab, the Database Window has been refreshed
with the new attribute applied to the table.

You don't mention if there's an error message involved, but using Reserved
words like Table and Properties will often cause trouble, so avoid them in
code. I was able to get the following example to hide/unhide the
tblProcedures table:

Public Sub testHideADOXTble()

Call hideADOXTbl("tblProcedures", True) ' Applies "Hidden"
attribute.
'Call hideADOXTbl("tblProcedures", False) ' Removes "Hidden"
attribute.

End Sub


Public Sub hideADOXTbl(sTableName As String, fHide As Boolean)

On Error GoTo ErrHandler

Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
Dim prp As ADOX.Property

Set cat.ActiveConnection = CurrentProject.Connection
Set tbl = cat.Tables(sTableName)
tbl.Properties("Jet OLEDB:Table Hidden In Access") = fHide

CleanUp:

Set tbl = Nothing
Set cat = Nothing

Exit Sub

ErrHandler:

MsgBox "Error in hideADOXTbl( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear
GoTo CleanUp

End Sub

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 

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