Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tag Property: Using to make group of fields visible-not visible 1

Status
Not open for further replies.

kptasteve

Programmer
Nov 2, 2002
43
US
I want to be able to begin using the Tag property to make groups of fields visible on a form. A short example would be to have a short and long version of a form based on how much information is needed. How it the TAG property used for this and to maybe set background colors based on a input reponse in a text field or yes/no box???

Steve Marcum PT
Programmer
 
Hi Steve,

Not entirely sure what you want here. If you set the Tag property on all the controls you want to control to some unique string, then you can loop through all the controls on the form and do whatever you want on those with that Tag, for example ...

Code:
Dim ctl As Control
Dim FullFormWanted As Boolean
FullFormWanted = True
Code:
' Set this according to your own conditions
Code:
For Each ctl In Me.Controls
    If ctl.Tag = "
Code:
UniqueString
Code:
" Then

        If FullFormWanted Then
            ctl.Visible = True
            If Me.
Code:
CheckBox
Code:
 = True Then
Code:
' Your test here
Code:
                ctl.BackColor = RGB(255, 0, 0)
Code:
' Red
Code:
            Else
                ctl.BackColor = RGB(0, 255, 0)
Code:
' Green
Code:
            End If
        Else
            ctl.Visible = False
        End If

    End If
Next

Enjoy,
Tony
 
While the illustrated function is certainly useful, the implementation is somewhat restrictive. The 'single' instance o "UniqueString" provides only one setting, while setting up a "PropertyBag" would permit a great deal of additional flexability. This ammounts to including a "PropName" as well as the value (with -of course- and assignment operator and a seperator) and parsing the Tag for the PropName when ever a specific item was to be used.

To "borrow" from TonyJollans's example, the Tag might be set up as:

CtrlVis = "visible", FontStyle = "vbItalic"

Then, the process of setting the value is to first parse the tag for the Token (PropName) of BkClr and assign the backcolor (not necessarily according to the literal value of the value)

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top