same code for same event on many controls?

  • Thread starter Thread starter Jesper F
  • Start date Start date
J

Jesper F

I have several forms with a lot of controls, many of which
are combo boxes.
For all the combos I'd like them to dropdown when they get
the focus.
Normally I would of course use:
me!comboname.dropdown
in the gotfocus event for each control, but is there an
easier way to do this for a lot of controls perhaps with
less code?
All controls on the forms are named "qstnX" where X is a
sequentiel number.
Thanks for any input.
 
You can write a function (not a sub) and call it in the GotFocus event of
all of the controls in question. To set the event for all of the controls at
once, select all of the controls. Whatever changes you put in the Properties
box will apply to all of them.

It's not clear to me from your question whether you need different code
depending on which control gets focus. If you do, you can check
Screen.ActiveControl in the function you write.
 
You can write a function (not a sub) and call it in the
GotFocus event of
all of the controls in question.

I did this using screen.activecontrol.dropdown and used
=dropdowncombo() in the property sheet.
It works beautifully. Thanks a lot.
 
Back
Top