exclude control from Me.Control

timothyl

Registered User.
Local time
Today, 16:50
Joined
Jun 4, 2009
Messages
92
Can some one tell me if there is a way to exclude a control from this statement

'Loop through each control on the form to get its value.
For Each ctl In Me.Controls
With ctl
Select Case .ControlType
Case acTextBox
.SetFocus

I tried the following, it did not work

For Each ctl In Me.Controls
where Me.Controls <> txtfrom
With ctl
Select Case .ControlType
Case acTextBox
.SetFocus
Thanks Tim
 
tim, try something like this:
Code:
For Each ctl In Me.Controls
   if typeof ctrl is textbox then
      ctl.setfocus
   end if
next ctl
what i wrote is just another way of using what you wrote to get the same thing.
 
How bout using the tag property to exclude it....
 
Thanks Adam, with a little playing that worked.

Curtis, if you are up for it, could you explained how to use the tag property to exclude a particular control from a group of controls, it seem like a useful thing to know. Thanks
 
Well, simply tag the ones you want to do something ( an asterisk in the tag property for example) with and leave others with no tag.... something this..


If ctl.ControlType = acTextBox Then
"do something"

ElseIf ctl.ControlType = acTextBox And ctl.Tag = "*" Then
"do something else"
else

End If

The tag property is handy to include or exclude whatever you like.
 
there are lots of possibilities

eg
you have ctrl.name, so you could explicitly test the name
you have ctrl.bgcolor or ctrl.forecolor (or something like) so you could test the color.
eg ignore lightgrey, but do the white ones

etc
 

Users who are viewing this thread

Back
Top Bottom