PC Review


Reply
Thread Tools Rate Thread

dbHiddenObject

 
 
Jim Pockmire
Guest
Posts: n/a
 
      3rd Jun 2005
Can you help me clean up the code below? I expect it to hide the named table
and it doesn't.

Function HideTable(acTable As String)
Dim DB As DAO.Database
Dim tdf As DAO.TableDef
Set DB = CurrentDb
Set tdf = DB.TableDefs(acTable)
tdf.Attributes = tdf.Attributes And dbHiddenObject
End Function

Ps, I do want care to use "Application.SetHiddenAttribute..."


 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      3rd Jun 2005
"Jim Pockmire" <(E-Mail Removed)> wrote in message
news:YEYne.22908$(E-Mail Removed)
> Can you help me clean up the code below? I expect it to hide the
> named table and it doesn't.
>
> Function HideTable(acTable As String)
> Dim DB As DAO.Database
> Dim tdf As DAO.TableDef
> Set DB = CurrentDb
> Set tdf = DB.TableDefs(acTable)
> tdf.Attributes = tdf.Attributes And dbHiddenObject
> End Function
>
> Ps, I do want care to use "Application.SetHiddenAttribute..."


Use "Or", not "And":

tdf.Attributes = tdf.Attributes Or dbHiddenObject

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

(please reply to the newsgroup)


 
Reply With Quote
 
Jim Pockmire
Guest
Posts: n/a
 
      3rd Jun 2005
I tried the substitution of "Or" for "And" and get a runtime 3001 error
"Invalid Argument". Ideas?

"Dirk Goldgar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Jim Pockmire" <(E-Mail Removed)> wrote in message
> news:YEYne.22908$(E-Mail Removed)
>> Can you help me clean up the code below? I expect it to hide the
>> named table and it doesn't.
>>
>> Function HideTable(acTable As String)
>> Dim DB As DAO.Database
>> Dim tdf As DAO.TableDef
>> Set DB = CurrentDb
>> Set tdf = DB.TableDefs(acTable)
>> tdf.Attributes = tdf.Attributes And dbHiddenObject
>> End Function
>>
>> Ps, I do want care to use "Application.SetHiddenAttribute..."

>
> Use "Or", not "And":
>
> tdf.Attributes = tdf.Attributes Or dbHiddenObject
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      3rd Jun 2005
"Jim Pockmire" <(E-Mail Removed)> wrote in message
news:aG_ne.35976$(E-Mail Removed)
> I tried the substitution of "Or" for "And" and get a runtime 3001
> error "Invalid Argument". Ideas?
>
> "Dirk Goldgar" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "Jim Pockmire" <(E-Mail Removed)> wrote in message
>> news:YEYne.22908$(E-Mail Removed)
>>> Can you help me clean up the code below? I expect it to hide the
>>> named table and it doesn't.
>>>
>>> Function HideTable(acTable As String)
>>> Dim DB As DAO.Database
>>> Dim tdf As DAO.TableDef
>>> Set DB = CurrentDb
>>> Set tdf = DB.TableDefs(acTable)
>>> tdf.Attributes = tdf.Attributes And dbHiddenObject
>>> End Function
>>>
>>> Ps, I do want care to use "Application.SetHiddenAttribute..."

>>
>> Use "Or", not "And":
>>
>> tdf.Attributes = tdf.Attributes Or dbHiddenObject


The corrected code:

'----- start of code -----
Function HideTable(acTable As String)
Dim DB As DAO.Database
Dim tdf As DAO.TableDef
Set DB = CurrentDb
Set tdf = DB.TableDefs(acTable)
tdf.Attributes = tdf.Attributes Or dbHiddenObject
End Function

'----- end of code -----

works fine for me, though I would never use "acTable" as the name for a
variable or parameter, because there is a defined constant by that name.
However, as I said, this code works for me. Which exact line is raising
the error?

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

(please reply to the newsgroup)


 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      3rd Jun 2005
"Jim Pockmire" <(E-Mail Removed)> wrote in news:YEYne.22908
$(E-Mail Removed):

> tdf.Attributes = tdf.Attributes And dbHiddenObject
>


As Dirk says, you set a bit using the Or operator, not And.

Moreover, you do know that dbHiddenObject does not actually do what you
want, don't you? dbHiddenObject marks the object for deletion when the file
is closed.

You are probably better off with

Application.SetHiddenAttribute (ObjectType, ObjectName, fHidden)

which is in the help file


Hope that helps


Tim F

 
Reply With Quote
 
Jim Pockmire
Guest
Posts: n/a
 
      3rd Jun 2005
Thank you,

I changed the name "acTable" to "strTable" and I no longer get the error
message. Is it possible (o reverse this and make the table visible (how)?


"Dirk Goldgar" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "Jim Pockmire" <(E-Mail Removed)> wrote in message
> news:aG_ne.35976$(E-Mail Removed)
>> I tried the substitution of "Or" for "And" and get a runtime 3001
>> error "Invalid Argument". Ideas?
>>
>> "Dirk Goldgar" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> "Jim Pockmire" <(E-Mail Removed)> wrote in message
>>> news:YEYne.22908$(E-Mail Removed)
>>>> Can you help me clean up the code below? I expect it to hide the
>>>> named table and it doesn't.
>>>>
>>>> Function HideTable(acTable As String)
>>>> Dim DB As DAO.Database
>>>> Dim tdf As DAO.TableDef
>>>> Set DB = CurrentDb
>>>> Set tdf = DB.TableDefs(acTable)
>>>> tdf.Attributes = tdf.Attributes And dbHiddenObject
>>>> End Function
>>>>
>>>> Ps, I do want care to use "Application.SetHiddenAttribute..."
>>>
>>> Use "Or", not "And":
>>>
>>> tdf.Attributes = tdf.Attributes Or dbHiddenObject

>
> The corrected code:
>
> '----- start of code -----
> Function HideTable(acTable As String)
> Dim DB As DAO.Database
> Dim tdf As DAO.TableDef
> Set DB = CurrentDb
> Set tdf = DB.TableDefs(acTable)
> tdf.Attributes = tdf.Attributes Or dbHiddenObject
> End Function
>
> '----- end of code -----
>
> works fine for me, though I would never use "acTable" as the name for a
> variable or parameter, because there is a defined constant by that name.
> However, as I said, this code works for me. Which exact line is raising
> the error?
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      4th Jun 2005
"Jim Pockmire" <(E-Mail Removed)> wrote in message
news:NN0oe.22985$(E-Mail Removed)
> Thank you,
>
> I changed the name "acTable" to "strTable" and I no longer get the
> error message.


Interesting. In my version, it worked even without that. I'm running
Access 2002 -- what are you running?

> Is it possible (o reverse this and make the table
> visible (how)?


How about this:

'------ start of code ------
Function ShowTable(strTable As String)
Dim DB As DAO.Database
Dim tdf As DAO.TableDef
Set DB = CurrentDb
Set tdf = DB.TableDefs(strTable)
tdf.Attributes = tdf.Attributes And (Not dbHiddenObject)
Set tdf = Nothing
Set DB = Nothing
End Function
'------ end of code ------

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

(please reply to the newsgroup)


 
Reply With Quote
 
Jim Pockmire
Guest
Posts: n/a
 
      4th Jun 2005
Thanks again,

My testing has been with a local table which hides/unhides fine. However
when running the code for a linked table, once again I receive a runtime
3001 error "Invalid Argument". Is this behavior normal?

"Dirk Goldgar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Jim Pockmire" <(E-Mail Removed)> wrote in message
> news:NN0oe.22985$(E-Mail Removed)
>> Thank you,
>>
>> I changed the name "acTable" to "strTable" and I no longer get the
>> error message.

>
> Interesting. In my version, it worked even without that. I'm running
> Access 2002 -- what are you running?
>
>> Is it possible (o reverse this and make the table
>> visible (how)?

>
> How about this:
>
> '------ start of code ------
> Function ShowTable(strTable As String)
> Dim DB As DAO.Database
> Dim tdf As DAO.TableDef
> Set DB = CurrentDb
> Set tdf = DB.TableDefs(strTable)
> tdf.Attributes = tdf.Attributes And (Not dbHiddenObject)
> Set tdf = Nothing
> Set DB = Nothing
> End Function
> '------ end of code ------
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      4th Jun 2005
"Jim Pockmire" <(E-Mail Removed)> wrote in message
news:4ohoe.20956$(E-Mail Removed)
> Thanks again,
>
> My testing has been with a local table which hides/unhides fine.
> However when running the code for a linked table, once again I
> receive a runtime 3001 error "Invalid Argument". Is this behavior
> normal?


I hadn't tried this before, but I'm finding the same thing. My guess is
that, since this attribute is really supposed to be for use by the Jet
database engine, it won't let you set it for an attached table. That's
just a guess, though. If you *must* hide tables using the
dbHiddenObject attribute, instead of Application.SetHiddenObject (or
just naming them with the USys prefix), then I think you're probably
stuck as far as linked tables are concerned. You've been warned about
how dbHiddenObjects may be deleted -- at least in some versions of
Access -- when the database is compacted, right?

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

(please reply to the newsgroup)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using dbHiddenObject Microsoft Access Security 1 3rd Nov 2003 10:28 PM
dbHiddenObject table attribute Vic Spainhower Microsoft Access 4 21st Sep 2003 05:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:03 AM.