473,422 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

better way

hey all.. is there a better way to do this:

If IsNull(Forms!formquerybuilder.Controls!cboxupsourc e) = 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.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200512/1
Dec 20 '05 #1
3 1144
ka******@comcast.net via AccessMonster.com wrote:
hey all.. is there a better way to do this:

If IsNull(Forms!formquerybuilder.Controls!cboxupsourc e) = 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.


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!cboxupsourc e) = 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

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Dec 20 '05 #2
"ka******@comcast.net via AccessMonster.com" <u15580@uwe> wrote
in news:591780ee69dd8@uwe:
hey all.. is there a better way to do this:

If IsNull(Forms!formquerybuilder.Controls!cboxupsourc e) =
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.

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.

--
Bob Quintal

PA is y I've altered my email address.
Dec 20 '05 #3
On Tue, 20 Dec 2005 00:39:38 GMT, "ka******@comcast.net via
AccessMonster.com" <u15580@uwe> wrote:

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:

If IsNull(Forms!formquerybuilder.Controls!cboxupsourc e) = 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.


Dec 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
3
by: Muhd | last post by:
<usualDisclaimer>Please forgive me if this is in the wrong group, and if so, what is the right group.</usualDisclaimer> Let me start off by first saying im a newb. Ok, with that out of the way I...
24
by: Faith Dorell | last post by:
I really don´t like C.You can write better programs in BASIC than in C, if you don´t like this language. I don´t understand how C became so popular, although much better programming languages...
43
by: Rob R. Ainscough | last post by:
I realize I'm learning web development and there is a STEEP learning curve, but so far I've had to learn: HTML XML JavaScript ASP.NET using VB.NET ..NET Framework ADO.NET SSL
33
by: Protoman | last post by:
Which is better for general-purpose programming, C or C++? My friend says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
22
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at...
19
by: Alexandre Badez | last post by:
I'm just wondering, if I could write a in a "better" way this code lMandatory = lOptional = for arg in cls.dArguments: if arg is True: lMandatory.append(arg) else: lOptional.append(arg)...
23
by: mike3 | last post by:
Hi. (posted to both newsgroups since I was not sure of which would be appropriate for this question or how specific to the given language it is. If one of them is inappropriate, just don't send...
20
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got the following C++ code. The first routine runs in...
3
by: Ryan Liu | last post by:
Hi, Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than synchronous I/O? At least as good? When I don't concern about easy or difficult to write code, should I always...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.