Evo nekoliko primera gde se koristi TAG da bi se manipulisalo kontrolama. Jedna od njih radi bas ono sto trazis - sakriva TAGirane kontrole. jedan moj poznanik je ovo dosta davno napisao, radi, provereno. Procitaj neka zapazanja, posle koda.
Code:
Function ClearControls(frm As Form, strTAG As String) As Boolean
'*******************************************
'Name: ClearControls (Function)
'Purpose: Clears all controls on the given form that
' have specified strTAg in their Tag property
'Author: Dejan
'Date: February 16, 2000, 02:57:47 PM
'Called by:
'Calls:
'Inputs:
'Output: nothing
'*******************************************
Dim ctl As Control
For Each ctl In frm.Controls
If InStr(1, ctl.Tag, strTAG) > 0 Then
ctl.Value = Null
End If
Next
End Function
Function ToggleVisible(frm As Form, strTAG As String) As Boolean
'*******************************************
'Name: ToggleVisible (Function)
'Purpose: toggle controls' visibility, for controls that have strTAG
' somewhere in their Tag property
'Author: Dejan
'Date: February 22, 2000, 02:08:19 PM
'Called by:
'Calls:
'Inputs: frm:=form hat contains controls
' strTAG:= code to be found in the Tag property. If found, visibility will be toggled
'Output: nothing
'*******************************************
Dim ctl As Control
For Each ctl In frm.Controls
If InStr(1, ctl.Tag, strTAG) > 0 Then
ctl.Visible = Not ctl.Visible
End If
Next
End Function
Function ToggleVisibleRep(rep As Report, strTAG As String) As Boolean
'*******************************************
'Name: ToggleVisible (Function)
'Purpose: toggle controls' visibility, for controls that have strTAG
' somewhere in their Tag property
'Author: Dejan
'Date: February 22, 2000, 02:08:19 PM
'Called by:
'Calls:
'Inputs: frm:=form hat contains controls
' strTAG:= code to be found in the Tag property. If found, visibility will be toggled
'Output: nothing
'*******************************************
Dim ctl As Control
For Each ctl In rep.Controls
If InStr(1, ctl.Tag, strTAG) > 0 Then
ctl.Visible = Not ctl.Visible
End If
Next
End Function
Primeti da ove funkcije dozvoljavaju da TAG bude slozen string. Na primer Tage = 'CLEAR_INVISIBLE' ima dva 'koda', CLEAR i INVISIBLE. Navedene funkcije proveravaju sadrzaj Tag-a funkcijom instr. Tako, mozes da pozoves funkciju ToggleVisible kao
ToggleVisible (frm:= frmMojaForma, strTAG = 'INVISIBLE') i to ce promeniti vidljivost svih kontrola koje TAG-u negde imaju string CLEAR.Ovo povecava vrednost Tag-a mnogostruko - koristis TAg za vise od jedne 'property'