Discussion:
ocultar/desocultar tablas al salir/entrar en BD
(demasiado antiguo para responder)
Sid
2005-05-09 15:40:53 UTC
Permalink
Hola amigos

Hay algun codigo que pueda utilizar para ocultar o desocultar las
tablas de la Base de Datos?

Es decir, que de alguna forma al abrirse el formulario inicial, las
tablas se hagan visibles y lo contrario cuando cerramos la aplicacion
desde el boton que a tal efecto se coloca en dicho formulario.

La base de datos esta dividida; por una lado estan los
procedimientos: BDComic.mdb, y por otra las tablas, TBLComic.mdb
vinculadas.

En San Google encontre este codigo, pero el autor no explica como
utilizarlo:

Public Function AWHideTable(opHIDE As Boolean)
Dim tblTMP As TableDef
For Each tblTMP In CurrentDb.TableDefs
With tblTMP
If .Attributes = dbAttachedTable And opHIDE Then
.Attributes = dbHiddenObject
ElseIf .Attributes = (dbAttachedTable + dbHiddenObject) And Not
opHIDE Then
.RefreshLink
ElseIf .Attributes = 0 And opHIDE Then
.Attributes = dbHiddenObject
ElseIf .Attributes = 1 And Not opHIDE Then
.Attributes = 0
End If
End With
Next
Application.RefreshDatabaseWindow
End Function
Lirán Marino
2005-05-09 16:12:41 UTC
Permalink
GetHiddenAttribute, SetHiddenAttribute Methods



a.. The GetHiddenAttribute method returns the value of hidden attribute of
a Microsoft Access object in the object's Properties dialog box, available
by selecting the object in the Database window and clicking Properties on
the View menu.


b.. The SetHiddenAttribute method sets the hidden attribute of an Access
object.

Syntax

object.GetHiddenAttribute(objecttype, objectname)

object.SetHiddenAttribute objecttype, objectname, setting

The GetHiddenAttribute and SetHiddenAttribute methods have the following
arguments.

Argument Description
object Optional. The Application object.
objecttype One of the following intrinsic constants:
acDataAccessPage
acDiagram
acForm
acMacro
acModule
acQuery
acReport
acServerView
acStoredProcedure
acTable

You must enter a constant for the objecttype argument, acDefault is
not a valid entry.
objectname A string expression identifying the name of the Access
object.
setting A Boolean value where True (-1) sets the hidden attribute and
False (0) clears the attribute.


Remarks

The GetHiddenAttribute and SetHiddenAttribute methods provide a means of
changing an object's hidden attribute from Visual Basic code. With these
methods, you can set or read the hidden option available in the object's
Properties dialog box.

Since the hidden attributes that the user can set by selecting or clearing a
check box, the GetHiddenAttribute method returns True (1) if the option
setting is Yes (the check box is selected) or False (0) if the option
setting is No (the check box is cleared). To set an option of this kind by
using the SetHiddenAttribute method, specify True or False for the setting
argument, as in the following example:

Application.SetHiddenAttribute acTable,"Customers", True
--
Liran Marino
liran (.) marino (@) gmail (.) com
-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-
Este mensaje se proporciona "TAL COMO ESTA", sin garantias y no otorga
ningun
derecho

-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-
(Guía de netiquette del foro)
http://www.uyssoft.com/Netiquette/

-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-·-
Las listas de News son como el Tetris, para la gente que aun recuerda como
leer...
Post by Sid
Hola amigos
Hay algun codigo que pueda utilizar para ocultar o desocultar las
tablas de la Base de Datos?
Es decir, que de alguna forma al abrirse el formulario inicial, las
tablas se hagan visibles y lo contrario cuando cerramos la aplicacion
desde el boton que a tal efecto se coloca en dicho formulario.
La base de datos esta dividida; por una lado estan los
procedimientos: BDComic.mdb, y por otra las tablas, TBLComic.mdb
vinculadas.
En San Google encontre este codigo, pero el autor no explica como
Public Function AWHideTable(opHIDE As Boolean)
Dim tblTMP As TableDef
For Each tblTMP In CurrentDb.TableDefs
With tblTMP
If .Attributes = dbAttachedTable And opHIDE Then
.Attributes = dbHiddenObject
ElseIf .Attributes = (dbAttachedTable + dbHiddenObject) And Not
opHIDE Then
.RefreshLink
ElseIf .Attributes = 0 And opHIDE Then
.Attributes = dbHiddenObject
ElseIf .Attributes = 1 And Not opHIDE Then
.Attributes = 0
End If
End With
Next
Application.RefreshDatabaseWindow
End Function
Sid
2005-05-09 19:33:40 UTC
Permalink
Gracias por la respueta Lirán

Entiendo, mas o menos, el trasfondo de dichos atributos pero lo que yo
quiero saber es como utilizar el codigo que indico ya que no tengo
claro donde colocarlo y llamarlo. Además no se si funciona porque el
post de donde lo recogí no lo indicaba.


En fecha Mon, 9 May 2005 18:12:41 +0200, el usuario del nick "Lirán
Post by Lirán Marino
GetHiddenAttribute, SetHiddenAttribute Methods
a.. The GetHiddenAttribute method returns the value of hidden attribute of
a Microsoft Access object in the object's Properties dialog box, available
by selecting the object in the Database window and clicking Properties on
the View menu.
b.. The SetHiddenAttribute method sets the hidden attribute of an Access
object.
Syntax
object.GetHiddenAttribute(objecttype, objectname)
object.SetHiddenAttribute objecttype, objectname, setting
The GetHiddenAttribute and SetHiddenAttribute methods have the following
arguments.
Argument Description
object Optional. The Application object.
acDataAccessPage
acDiagram
acForm
acMacro
acModule
acQuery
acReport
acServerView
acStoredProcedure
acTable
You must enter a constant for the objecttype argument, acDefault is
not a valid entry.
objectname A string expression identifying the name of the Access
object.
setting A Boolean value where True (-1) sets the hidden attribute and
False (0) clears the attribute.
Remarks
The GetHiddenAttribute and SetHiddenAttribute methods provide a means of
changing an object's hidden attribute from Visual Basic code. With these
methods, you can set or read the hidden option available in the object's
Properties dialog box.
Since the hidden attributes that the user can set by selecting or clearing a
check box, the GetHiddenAttribute method returns True (1) if the option
setting is Yes (the check box is selected) or False (0) if the option
setting is No (the check box is cleared). To set an option of this kind by
using the SetHiddenAttribute method, specify True or False for the setting
Application.SetHiddenAttribute acTable,"Customers", True
Juan M Afan de Ribera
2005-05-09 20:04:47 UTC
Permalink
-----------------------------------------------------------------------
Por favor, responde a este mensaje y dinos si te funcionó o no. Gracias
-----------------------------------------------------------------------

Sid,

si no utilizas Access 97 entonces puedes usar ese código que mencionas (en
Access 97, si ejecutas ese código y después compactas la base de datos,
Access borrará esas tablas que hayas ocultado con ese atributo)

Para hacer servir esa función basta con que la llames desde algún punto de
tu código de esta manera:

Call AWHideTable(True) ' para ocultar tablas
Call AWHideTable(False) ' para volver a mostrar las tablas

el otro método que te citan se utilizaría de esta otra forma.

Application.SetHiddenAttribute acTable,"Customers", True

para ocultar la tabla llamada "Customers"

Igualmente, podrías repasar el curso de Eduardo Olaz sobre Access y VBA, ya
que me parece algo "peligroso" utilizar código sin saber algunas cosas
básicas, como puede ser el hecho de llamar a una función o procedimiento.
Está aquí

http://www.olaz.net/descargas/access/curso_vba/vba_entregas.htm
http://www.mvp-access.com/foro/forum_topics.asp?FID=19

No te ofendas por lo que digo aquí, no lo hago con esa intención. Lo digo en
serio, el código es mejor entenderlo e ir utilizándolo a medida que lo vayas
asimilando. Si no, al primer problema que tengas puedes encontrarte
bloqueado y a lo mejor tu aplicación ha crecido en base a algún código que
no controlas. ¿qué harás entonces?

Saludos,
Juan M Afan de Ribera
[MVP Access]
http://www.mvp-access.com/accessvbafaq
http://www.mvp-access.com/juanmafan
Post by Sid
Gracias por la respueta Lirán
Entiendo, mas o menos, el trasfondo de dichos atributos pero lo que yo
quiero saber es como utilizar el codigo que indico ya que no tengo
claro donde colocarlo y llamarlo. Además no se si funciona porque el
post de donde lo recogí no lo indicaba.
En fecha Mon, 9 May 2005 18:12:41 +0200, el usuario del nick "Lirán
Post by Lirán Marino
GetHiddenAttribute, SetHiddenAttribute Methods
a.. The GetHiddenAttribute method returns the value of hidden attribute of
a Microsoft Access object in the object's Properties dialog box, available
by selecting the object in the Database window and clicking Properties on
the View menu.
b.. The SetHiddenAttribute method sets the hidden attribute of an Access
object.
Syntax
object.GetHiddenAttribute(objecttype, objectname)
object.SetHiddenAttribute objecttype, objectname, setting
The GetHiddenAttribute and SetHiddenAttribute methods have the following
arguments.
Argument Description
object Optional. The Application object.
acDataAccessPage
acDiagram
acForm
acMacro
acModule
acQuery
acReport
acServerView
acStoredProcedure
acTable
You must enter a constant for the objecttype argument, acDefault is
not a valid entry.
objectname A string expression identifying the name of the Access
object.
setting A Boolean value where True (-1) sets the hidden attribute and
False (0) clears the attribute.
Remarks
The GetHiddenAttribute and SetHiddenAttribute methods provide a means of
changing an object's hidden attribute from Visual Basic code. With these
methods, you can set or read the hidden option available in the object's
Properties dialog box.
Since the hidden attributes that the user can set by selecting or clearing a
check box, the GetHiddenAttribute method returns True (1) if the option
setting is Yes (the check box is selected) or False (0) if the option
setting is No (the check box is cleared). To set an option of this kind by
using the SetHiddenAttribute method, specify True or False for the setting
Application.SetHiddenAttribute acTable,"Customers", True
Sid
2005-05-10 14:39:02 UTC
Permalink
Muchas gracias por tus buenos consejos.
Efectivamente, gracias al curso de Olaz he avanzado mucho en access,
ya que hasta hace poco mas de dos meses solo conocía de su existencia.
El problema es el tiempo; por desgracia no tengo mucho disponible, por
eso aprovecho los fines de semana para practicar.

Gracias nuevamente




En fecha Mon, 9 May 2005 22:04:47 +0200, el usuario del nick "Juan M
Post by Juan M Afan de Ribera
-----------------------------------------------------------------------
Por favor, responde a este mensaje y dinos si te funcionó o no. Gracias
-----------------------------------------------------------------------
Sid,
si no utilizas Access 97 entonces puedes usar ese código que mencionas (en
Access 97, si ejecutas ese código y después compactas la base de datos,
Access borrará esas tablas que hayas ocultado con ese atributo)
Para hacer servir esa función basta con que la llames desde algún punto de
Call AWHideTable(True) ' para ocultar tablas
Call AWHideTable(False) ' para volver a mostrar las tablas
el otro método que te citan se utilizaría de esta otra forma.
Application.SetHiddenAttribute acTable,"Customers", True
para ocultar la tabla llamada "Customers"
Igualmente, podrías repasar el curso de Eduardo Olaz sobre Access y VBA, ya
que me parece algo "peligroso" utilizar código sin saber algunas cosas
básicas, como puede ser el hecho de llamar a una función o procedimiento.
Está aquí
http://www.olaz.net/descargas/access/curso_vba/vba_entregas.htm
http://www.mvp-access.com/foro/forum_topics.asp?FID=19
No te ofendas por lo que digo aquí, no lo hago con esa intención. Lo digo en
serio, el código es mejor entenderlo e ir utilizándolo a medida que lo vayas
asimilando. Si no, al primer problema que tengas puedes encontrarte
bloqueado y a lo mejor tu aplicación ha crecido en base a algún código que
no controlas. ¿qué harás entonces?
Saludos,
Juan M Afan de Ribera
[MVP Access]
http://www.mvp-access.com/accessvbafaq
http://www.mvp-access.com/juanmafan
Post by Sid
Gracias por la respueta Lirán
Entiendo, mas o menos, el trasfondo de dichos atributos pero lo que yo
quiero saber es como utilizar el codigo que indico ya que no tengo
claro donde colocarlo y llamarlo. Además no se si funciona porque el
post de donde lo recogí no lo indicaba.
En fecha Mon, 9 May 2005 18:12:41 +0200, el usuario del nick "Lirán
Post by Lirán Marino
GetHiddenAttribute, SetHiddenAttribute Methods
a.. The GetHiddenAttribute method returns the value of hidden attribute of
a Microsoft Access object in the object's Properties dialog box, available
by selecting the object in the Database window and clicking Properties on
the View menu.
b.. The SetHiddenAttribute method sets the hidden attribute of an Access
object.
Syntax
object.GetHiddenAttribute(objecttype, objectname)
object.SetHiddenAttribute objecttype, objectname, setting
The GetHiddenAttribute and SetHiddenAttribute methods have the following
arguments.
Argument Description
object Optional. The Application object.
acDataAccessPage
acDiagram
acForm
acMacro
acModule
acQuery
acReport
acServerView
acStoredProcedure
acTable
You must enter a constant for the objecttype argument, acDefault is
not a valid entry.
objectname A string expression identifying the name of the Access
object.
setting A Boolean value where True (-1) sets the hidden attribute and
False (0) clears the attribute.
Remarks
The GetHiddenAttribute and SetHiddenAttribute methods provide a means of
changing an object's hidden attribute from Visual Basic code. With these
methods, you can set or read the hidden option available in the object's
Properties dialog box.
Since the hidden attributes that the user can set by selecting or clearing a
check box, the GetHiddenAttribute method returns True (1) if the option
setting is Yes (the check box is selected) or False (0) if the option
setting is No (the check box is cleared). To set an option of this kind by
using the SetHiddenAttribute method, specify True or False for the setting
Application.SetHiddenAttribute acTable,"Customers", True
Loading...