[AccessD] Making Labels Visible & Invisible

John W. Colby jcolby at colbyconsulting.com
Thu Dec 4 07:48:18 CST 2003


Sure, do something like (NOT compiled / tested)

Dim colLabel As Collection

Function CollectLabels()
    Set colLabel = New Collection
    colLabel.Add CL_Client_Label
    colLabel.Add Product_Label
    colLabel.Add Label85
    colLabel.Add Label116
End Function

Private Sub Form_Open(Cancel As Integer)
    CollectLabels
end sub

Function SetLblVisible(col As Collection, blnVisible As Boolean)
Dim obj As Object
    For Each obj In col
        obj.Visible = blnVisible
    Next obj
End Function

Private Sub Command131_Click()
Static blnVisible As Boolean
    SetLblVisible colLabel, blnVisible
    blnVisible = Not blnVisible
End Sub

The form Open collects all the labels into a collection.  The button passes
the collection and a boolean value for the visible property into a function
which iterates the collection and sets the object's visible property to
whatever you pass in.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of
paul.hartland at fsmail.net
Sent: Thursday, December 04, 2003 8:24 AM
To: accessd
Subject: [AccessD] Making Labels Visible & Invisible


To all,

I have a group of labels on a form called lblComment1 through to
lblComment15, and what I want to do is in the OnCurrentEvent make them all
invisible.  I don’t really want to have to type

Me.lblComment1.Visible = False

etc for every label




Is there a way I can do this in a loop, or make the labels into an array and
loop through them that way.

Thanks in advance for any help on this.

Paul Hartland
Freeserve AnyTime - HALF PRICE for the first 3 months - Save £7.50 a month
www.freeserve.com/anytime
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list