My Assistant
![]() ![]() |
|
|
Apr 20 2009, 06:18 PM
Post
#1
|
|
|
UtterAccess Guru Posts: 503 |
Hey guys
I'm trying to set the visibility property for controls with a Tag property of "G1" or "G2" to True. Is my logic here correct? I'm sure I'm missing something (as it's not working). Here's my code: CODE For Each ctl In Me If ctl.Tag = G1 Or G2 Then ctl.Visible = True End If Next |
|
|
|
Apr 20 2009, 06:21 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 7,132 From: Perris, California |
Try
CODE For Each ctl In Me If ctl.Tag = "G1" Or ctl.Tag = "G2" Then ctl.Visible = True End If Next |
|
|
|
Apr 20 2009, 06:25 PM
Post
#3
|
|
|
Retired Moderator Posts: 37,716 From: The San Francisco Bay Area |
My best guess, but search Access help for more details...
CODE Dim ctl as Control For Each ctl in Me.Controls If ctl.ControlType = acTextBox Then ...your if ctl.tag... code End if Next Don't forget the Else bit if you want the control to remain hidden.... hth, Jack PS. If ctl.Tag = "G1" or if ctl.Tag = "G2" Then |
|
|
|
Apr 20 2009, 06:27 PM
Post
#4
|
|
|
Retired Moderator Posts: 37,716 From: The San Francisco Bay Area |
Anthony -
You ARE thinking about all those fish you never caught at HB pier...right? (IMG:http://www.utteraccess.com/forum/style_emoticons/default/wink.gif) Jack |
|
|
|
Apr 20 2009, 06:40 PM
Post
#5
|
|
|
Utterly Banned Posts: 7,038 |
Jack and Anthony each got it partially right but in your case you don't need to check for a text box type so it would just be:
CODE For Each ctl In Me[color="red"].Controls [/color]
If ctl.Tag = [color="red"]"G1" Or ctl.Tag = "G2"[/color] Then ctl.Visible = True End If Next |
|
|
|
Apr 20 2009, 06:41 PM
Post
#6
|
|
|
UtterAccess VIP Posts: 7,132 From: Perris, California |
bob,
I missed the .Controls - however, the IF Statement is still malformed. |
|
|
|
Apr 20 2009, 06:49 PM
Post
#7
|
|
|
Retired Moderator Posts: 37,716 From: The San Francisco Bay Area |
Bob -
Thank goodness someone is clear headed and not affected by the heat or trips to the wine cellar! Thank you for jumping!!! Jack |
|
|
|
Apr 20 2009, 06:52 PM
Post
#8
|
|
|
UtterAccess VIP Posts: 7,132 From: Perris, California |
BAH! He edited it, now I look the fool, (IMG:http://www.utteraccess.com/forum/style_emoticons/default/laugh.gif)
|
|
|
|
Apr 20 2009, 06:54 PM
Post
#9
|
|
|
Utterly Banned Posts: 7,038 |
QUOTE BAH! He edited it, now I look the fool, (IMG:http://www.utteraccess.com/forum/style_emoticons/default/laugh.gif) only a little <roflmao> (IMG:http://www.utteraccess.com/forum/style_emoticons/default/laugh.gif) |
|
|
|
Apr 20 2009, 07:25 PM
Post
#10
|
|
|
UtterAccess Guru Posts: 503 |
Thanks for the help guys. (IMG:http://www.utteraccess.com/forum/style_emoticons/default/sad.gif)
|
|
|
|
Apr 20 2009, 08:19 PM
Post
#11
|
|
|
UtterAccess Guru Posts: 503 |
Sorry guys - futher to that.
How do you then do the same with labels? |
|
|
|
Apr 20 2009, 09:37 PM
Post
#12
|
|
|
UtterAccess Ruler Posts: 2,659 |
If ctl.ControlType = acTextBox or ctl.ControlType = acLabel Then
The secret to using this kind of code without bombing is to make sure the property you're trying to set is avaiialable to the control type. In other words, you can use the above if you're setting the Visibility property, because both textboxes and labels have a Visibility property. But if you tried to use it to set the Lock property, it would bomb, because labels don't have a Lock property! |
|
|
|
Apr 20 2009, 10:54 PM
Post
#13
|
|
|
Utterly Banned Posts: 7,038 |
QUOTE If ctl.ControlType = acTextBox or ctl.ControlType = acLabel Then The secret to using this kind of code without bombing is to make sure the property you're trying to set is avaiialable to the control type. In other words, you can use the above if you're setting the Visibility property, because both textboxes and labels have a Visibility property. But if you tried to use it to set the Lock property, it would bomb, because labels don't have a Lock property! The code I provided would not necessarily bomb if the .Lock property was used. It would only bomb if a tag of G1 or G2 was on a non-lockable control. So, actually using tags CAN be easier to use as you can put them on certain controls and, as long as you know what has what, you don't need to qualify by part. |
|
|
|
Apr 20 2009, 10:55 PM
Post
#14
|
|
|
Utterly Banned Posts: 7,038 |
QUOTE Sorry guys - futher to that. How do you then do the same with labels? Again - it is the same as with text boxes - the code I provided would make ANY control visible (text box or label, or option group, etc. as long as the tag G1 or G2 was on it. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 06:08 AM |