473,408 Members | 2,813 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,408 software developers and data experts.

With Statement

access 97

can someone tell me the syntax for a with stement for multiple
controls?

pseudo (doesn't work)

With cmbBox1,cmbBox2,cmbBox3
.Visible = False
End With

-doodle

Nov 13 '06 #1
4 5160

doodle wrote:
access 97

can someone tell me the syntax for a with stement for multiple
controls?

pseudo (doesn't work)

With cmbBox1,cmbBox2,cmbBox3
.Visible = False
End With

-doodle
AFAIK, you can't do that. You can create a subroutine in your form
that accepts a control/control name and then you can process them all
individually.

If all you're doing is setting items to visible, then just use
me.cmbBox1.visible=False

or you could use a boolean expression instead of just True or False.

Nov 13 '06 #2
On 13 Nov 2006 11:59:05 -0800, pi********@hotmail.com wrote:

Perhaps you could write:
dim varControls as Variant = Array("cmbBox1","cmbBox2","cmbBox3")
dim varControl as Variant
for each varControl in varControls
Me.Controls(varControl).Visible = False
next varControl

or if you KNOW the controls are numbered successively:
dim i as Integer
for i = 1 to 3
Me.Controls("cmbBox" & i).Visible = False
next i

There is also an interesting way to do it with additional parameters
passed to a function. I'll leave it up to you to read up on
ParamArray.

-Tom.
>
doodle wrote:
>access 97

can someone tell me the syntax for a with stement for multiple
controls?

pseudo (doesn't work)

With cmbBox1,cmbBox2,cmbBox3
.Visible = False
End With

-doodle

AFAIK, you can't do that. You can create a subroutine in your form
that accepts a control/control name and then you can process them all
individually.

If all you're doing is setting items to visible, then just use
me.cmbBox1.visible=False

or you could use a boolean expression instead of just True or False.
Nov 13 '06 #3
You don't appear to understand what the With statement is doing for you.

It provides a pointer to an object and cut down the overhead needed to
search for that object in all the objects you could be referring to.

So for your example you should be doing something like:-

With Me
With .cmbBox1
.Visible = False
End With

With .cmbBox2
.Visible = False
End With

With .cmbBox3
.Visible = False
End With
End With
--

Terry Kreft
"doodle" <AD******@mazakcorp.comwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
access 97

can someone tell me the syntax for a with stement for multiple
controls?

pseudo (doesn't work)

With cmbBox1,cmbBox2,cmbBox3
.Visible = False
End With

-doodle

Nov 14 '06 #4
Tom van Stiphout wrote:
On 13 Nov 2006 11:59:05 -0800, pi********@hotmail.com wrote:

Perhaps you could write:
dim varControls as Variant = Array("cmbBox1","cmbBox2","cmbBox3")
dim varControl as Variant
for each varControl in varControls
Me.Controls(varControl).Visible = False
next varControl

or if you KNOW the controls are numbered successively:
dim i as Integer
for i = 1 to 3
Me.Controls("cmbBox" & i).Visible = False
next i

There is also an interesting way to do it with additional parameters
passed to a function. I'll leave it up to you to read up on
ParamArray.

-Tom.
I like Tom's ideas. Here's a way to set the Visible property of all
comboboxes on an A97 form to False:

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acComboBox Then
With Controls(ctl.Name)
.Visible = False
End With
End If
Next ctl

You can set the Tag property to a value and use that to control which
comboboxes disappear:

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acComboBox Then
Select Case Me.Controls(ctl.Name).Tag
Case "HideMe":
With Controls(ctl.Name)
.Visible = False
End With
End Select
End If
Next ctl

Try not to double up on the Tag property. You won't like where that
road leads. Ditto for OpenArgs.

Dim ctl As Control

For Each ctl In Me.Controls
If Right(ctl.Name, 9) = "Ephemeral" Then
If ctl.ControlType = acComboBox Then
With Controls(ctl.Name)
.Visible = False
End With
End If
End If
Next ctl

sets the Visible property of comboboxes with a name ending in Ephemeral
to False.

It's also possible to use other combobox properties such as ForeColor,
which can have values that are just about indistinguishable from each
other. Each shade variation can identify a group of controls. Groups
of control groups can use a color difference metric, say R,G and B
being within one unit of a particular color. I hope this helps.

James A. Fortune
CD********@FortuneJames.com

A proverb is no proverb to you till life has illustrated it. -- John
Keats

Nov 15 '06 #5

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

Similar topics

68
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
3
by: Jason Callas | last post by:
I have a stored procedure that runs as a step in a scheduled job. For some reason the job does not seem to finish when ran from the job but does fine when run from a window in SQL Query. I know...
22
by: nobody | last post by:
hello everybody, is there a way of creating an array with help of a function that would accept the name of this array as a parameter and then create global Array type variable of that name? so...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
27
by: C Gillespie | last post by:
Dear All, Hopefully I have a simple problem. Basically, I just want to alter some text with JS. Here is some of my test code: <snip> <script type="text/javascript"> var tmp='a';
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
8
by: Rasmus Kromann-Larsen | last post by:
The With Conundrum I'm currently writing a master thesis on (preparations for) static analysis of JavaScript, and after investigating the with statement, it only even more evident to me that the...
5
oll3i
by: oll3i | last post by:
my librarybean package library.ejb; import java.sql.*; import javax.ejb.*; import library.common.*; @Stateless @Remote
2
jwwicks
by: jwwicks | last post by:
C/C++ Programs and Debugging in Linux This tutorial will give you a basic idea how to debug a program in Linux using GDB. As you are aware Visual Studio doesn’t run on Linux so you have to use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.