Group Controls For One Event

  • Thread starter Thread starter Microsoft Access
  • Start date Start date
M

Microsoft Access

I would like to be able to group a bunch of text boxes on my form so that if
something changes in any of them I can use the onchange event for the group
and not have to add code for all textboxes. Is this possible? Thanks.
 
There are different ways to achieve that. Are the specified controls al
textboxes or.. what makes the distinction.

The 'tag' property of the control is often used for checking groups of
controls.

Example:

alle the controls that have "hide" in them should be hidden after a certain
action.
set every tag of the specified controls to "Hide" and then the following
under the event handler
code:

dim ctl as control
for each ctl in me
if ctl.tag="hide" then
ctl.visible=false
else
'you could do something alternative here otherwise leave the else out
end if
next


hth
 
I would like to be able to group a bunch of text boxes on my form so that if
something changes in any of them I can use the onchange event for the group
and not have to add code for all textboxes. Is this possible? Thanks.

Watch out: the Change event's name is a bit misleading. You may want the
AfterUpdate event instead - the Change event fires at every keystroke,
AfterUpdate when a new value has been entered and the user leaves the control.

That said... no, you can't do this directly, but you can create a Function in
the form's module, and put

=FunctionName(<arguments>)

in place of [Event Procedure] in the appropriate event of each textbox.
 
Thanks Maurice, that is an interesting solution. It wouldn't work here
because I am looking for an event to fire, but I think John addressed this
case. I will keep this idea in mind for the future though.
 
Thanks John, I will do what you said about adding the function to the event
in properties. Thanks for the thoughts.

John W. Vinson said:
I would like to be able to group a bunch of text boxes on my form so that
if
something changes in any of them I can use the onchange event for the
group
and not have to add code for all textboxes. Is this possible? Thanks.

Watch out: the Change event's name is a bit misleading. You may want the
AfterUpdate event instead - the Change event fires at every keystroke,
AfterUpdate when a new value has been entered and the user leaves the
control.

That said... no, you can't do this directly, but you can create a Function
in
the form's module, and put

=FunctionName(<arguments>)

in place of [Event Procedure] in the appropriate event of each textbox.
 
Back
Top