Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2006, 07:25 PM
doodle
Guest
 
Posts: n/a
Default 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

  #2  
Old November 13th, 2006, 07:35 PM
pietlinden@hotmail.com
Guest
 
Posts: n/a
Default Re: With Statement


doodle wrote:
Quote:
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.

  #3  
Old November 13th, 2006, 07:45 PM
Tom van Stiphout
Guest
 
Posts: n/a
Default Re: With Statement

On 13 Nov 2006 11:59:05 -0800, pietlinden@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.
Quote:
>
>doodle wrote:
Quote:
>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.
  #4  
Old November 14th, 2006, 09:55 PM
Terry Kreft
Guest
 
Posts: n/a
Default Re: With Statement

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" <ADraughn@mazakcorp.comwrote in message
news:1163447268.240473.284990@h54g2000cwb.googlegr oups.com...
Quote:
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
>

  #5  
Old November 15th, 2006, 03:25 AM
CDMAPoster@FortuneJames.com
Guest
 
Posts: n/a
Default Re: With Statement

Tom van Stiphout wrote:
Quote:
On 13 Nov 2006 11:59:05 -0800, pietlinden@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
CDMAPoster@FortuneJames.com

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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles