hey all.. is there a better way to do this:
If IsNull(Forms!formquerybuilder.Controls!cboxupsource) = False Then
Me!Text342.Visible = False
Me!Text352.Visible = False
Me!Label343.Visible = False
Me!Text205.Visible = False
Me!Text206.Visible = False
Me!txtboxsoldunits.Visible = False
Me!Text208.Visible = False
Me!Text355.Visible = False
Me!Label356.Visible = False
Me!Text357.Visible = False
Me!Label358.Visible = False
Me!Text371.Visible = False
Me!Text375.Visible = False
Me!Text378.Visible = False
End If
my way seems kinda long and i have a lot of it in different places. thanks.
Bob Quintal - 20 Dec 2005 00:59 GMT
> hey all.. is there a better way to do this:
>
[quoted text clipped - 18 lines]
> my way seems kinda long and i have a lot of it in different
> places. thanks.
It should be in only one place. If always referring to a single
form, create a sub in the form's code module and call that sub
from wherever you need the labels made invisible.
You can also loop through a form's object collection, if you are
setting all items of a class invisible. You can use the object's
.tag property as an additional filter. I find that more trouble
than just hard coding the statements.

Signature
Bob Quintal
PA is y I've altered my email address.
Rick Brandt - 20 Dec 2005 01:01 GMT
> hey all.. is there a better way to do this:
>
[quoted text clipped - 17 lines]
> my way seems kinda long and i have a lot of it in different places.
> thanks.
Long ago I wrote myself a handful of custom functions...
LockAll(FormName, tagString)
UnLockAll(FormName, tagString)
DisableAll(FormName, tagString)
EnableAll(FormName, tagString)
ShowAll(FormName, tagString)
HideAll(FormName, tagString)
They all work the same way. I enter into the Tag property of all of the
controls I want to manipulate a common string. The functions cycle through all
controls on the form testing to see if the supplied tagString is within the Tag
property of the control. If it is then the appropriate property is set for that
control.
In your case I could enter "Hide" as the tag property of all of those controls.
Then I would just use...
If IsNull(Forms!formquerybuilder.Controls!cboxupsource) = False Then
HideAll(Me.Name, "Hide")
Else
ShowAll(Me.Name, "Hide")
End If
Here is an example of the HideAll function...
Function HideAll(FormName as String, TagString as String)
Dim frm as Form
Dim cnt as Control
Set frm = Forms(FormName)
For Each cnt in frm
If cnt.Tag Like "*" & TagString & "*" Then
cnt.Visible = False
End If
Next cnt
End Function

Signature
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Tom van Stiphout - 21 Dec 2005 04:16 GMT
Certainly you could put this code in a procedure, and call it from
several places.
Additionally you could name the controls something more useful, so you
could actually read and understand the code.
You could also write somewhat generic code like below. Store the
control names in an array, and call code to loop over them. Then from
form to form the only thing you have to change is the array:
private sub ShowControls( byval blnShow as Boolean)
dim aryControlNames as Variant
dim c as Variant
aryControlNames = Array("txtFirstName", "txtLastName", "txtEtcetera")
for each c in aryControlNames
c.Visible = blnShow
next c
end sub
Call the function like this:
ShowControls True
or
ShowControls False
-Tom.
>hey all.. is there a better way to do this:
>
[quoted text clipped - 16 lines]
>
>my way seems kinda long and i have a lot of it in different places. thanks.