Romio_1968
Member
- Local time
- Today, 07:46
- Joined
- Jan 11, 2023
- Messages
- 126
I need to take group action on controls on a form, based on their tag
Let say, some of them I want to be hidden on load. I will assign them a tag "H"
For other, I want them to be disabled. Tag "D"
Other set to Null value.
So some of them may be similtaneously in more than one group of action
Let say that oane should be Nulled and hidden
I tried to assign two tags, sepparated by semicolon (tried also comma, dot,,,)
I created a function called ActionTag that will loop trough the controls and retrieve the tag.
Insede the function, a Case Select is set, and for each case the appropiate action is taken.
Works like a charm for one tag, but when come to multiple, the function ise dead. Nothing happens.
I tried to treat the Tag property content as an string and splitt it in an array.
Still nothing.
Any ideea how this can be done.
(see Mr. Hartman, you put my soul on fire now
)
------------------------------
RESOLUTION
Don't know yet what was going wrong but probably it was some typo or ill set property, call or event.
Also it is possible that a reddundancy in the old code may have lead to the error (I was rechecking for a Tag inside the Case for tahat Tag)
Here is an example of the code that works
Thank You theDBguy for testing
Let say, some of them I want to be hidden on load. I will assign them a tag "H"
For other, I want them to be disabled. Tag "D"
Other set to Null value.
So some of them may be similtaneously in more than one group of action
Let say that oane should be Nulled and hidden
I tried to assign two tags, sepparated by semicolon (tried also comma, dot,,,)
I created a function called ActionTag that will loop trough the controls and retrieve the tag.
Insede the function, a Case Select is set, and for each case the appropiate action is taken.
Works like a charm for one tag, but when come to multiple, the function ise dead. Nothing happens.
I tried to treat the Tag property content as an string and splitt it in an array.
Still nothing.
Any ideea how this can be done.
(see Mr. Hartman, you put my soul on fire now

------------------------------
RESOLUTION
Don't know yet what was going wrong but probably it was some typo or ill set property, call or event.
Also it is possible that a reddundancy in the old code may have lead to the error (I was rechecking for a Tag inside the Case for tahat Tag)
Here is an example of the code that works
Code:
Public Sub ActByTag(frm As Form)
Dim ctl As Control
Dim tags As Variant
Dim tag As Variant
For Each ctl In frm.Controls
tags = Split(ctl.tag, ";")
For Each tag In tags
Select Case tag
Case "Clear"
ctl.Value = ""
Case "Hide"
ctl.Visible = False
End Select
Next tag
Next ctl
End Sub
Thank You theDBguy for testing
Last edited: